gluu
公開メンバ関数 | 静的公開変数類 | 変数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.action.ManageCertificateAction クラス
org.gluu.oxtrust.action.ManageCertificateAction の継承関係図
Inheritance graph
org.gluu.oxtrust.action.ManageCertificateAction 連携図
Collaboration graph

公開メンバ関数

String init ()
 
void getCert (String fileName)
 
void getCert (TrustStoreCertificate trustStoreCertificate)
 
String generateCSR (String fileName) throws IOException
 
boolean compare (String fileName)
 
boolean certPresent (String filename)
 
String getIdpCertFN ()
 
String getTomcatCertFN ()
 
String getTempCertDir ()
 
HashMap< String, String > getIssuer ()
 
HashMap< String, String > getSubject ()
 
void setUploadMarker (String uploadMarker)
 
void setUploadMarker (TrustStoreCertificate trustStoreCertificate)
 
String update ()
 
void cancel ()
 
void certUpload (FileUploadEvent event)
 
void keyUpload (FileUploadEvent event)
 
void addPublicCertificate ()
 
void removePublicCertificate (TrustStoreCertificate removeTrustStoreCertificate)
 
boolean isInitialized ()
 
boolean isCertsManagePossible ()
 
TrustStoreConfiguration getTrustStoreConfiguration ()
 
List< TrustStoreCertificategetTrustStoreCertificates ()
 

静的公開変数類

static final String BEGIN_CERT_REQ = "-----BEGIN CERTIFICATE REQUEST-----"
 
static final String END_CERT_REQ = "-----END CERTIFICATE REQUEST-----"
 

変数

String tomcatCertFN
 
String idpCertFN
 

非公開メンバ関数

void loadCert (X509Certificate cert)
 
KeyPair getKeyPair (String fileName)
 
boolean prepareTempWorkspace ()
 
boolean updateTrustCertificates ()
 
boolean updateCertificates ()
 
void tirggerTrustStoreUpdate ()
 
void updateCert (UploadedFile item)
 
void updateTrsutStoreCert (UploadedFile item)
 
void updateKey (UploadedFile item)
 

非公開変数類

Logger log
 
OrganizationService organizationService
 
FacesMessages facesMessages
 
SSLService sslService
 
AppConfiguration appConfiguration
 
ApplianceService applianceService
 
Identity identity
 
TrustStoreConfiguration trustStoreConfiguration
 
List< TrustStoreCertificatetrustStoreCertificates
 
String orgInumFN
 
HashMap< String, String > issuer
 
HashMap< String, String > subject
 
String uploadMarker
 
TrustStoreCertificate trustStoreCertificateUploadMarker
 
boolean certsMmanagePossible
 
boolean initialized
 
boolean wereAnyChanges
 

静的非公開変数類

static final long serialVersionUID = 4012709440384265524L
 

詳解

Manages SSL certificates

著者
Oleksiy Tataryn
Yuriy Movchan Date: 03/03/2014

関数詳解

◆ addPublicCertificate()

void org.gluu.oxtrust.action.ManageCertificateAction.addPublicCertificate ( )
inline
586  {
587  TrustStoreCertificate trustStoreCertificate = new TrustStoreCertificate();
588  trustStoreCertificate.setAddedAt(new Date());
589  trustStoreCertificate.setAddedBy(identity.getUser().getDn());
590 
591  this.trustStoreCertificates.add(trustStoreCertificate);
592  }
Identity identity
Definition: ManageCertificateAction.java:102
GluuCustomPerson getUser()
Definition: Identity.java:39
List< TrustStoreCertificate > trustStoreCertificates
Definition: ManageCertificateAction.java:105

◆ cancel()

void org.gluu.oxtrust.action.ManageCertificateAction.cancel ( )
inline
518  {
519  }

◆ certPresent()

boolean org.gluu.oxtrust.action.ManageCertificateAction.certPresent ( String  filename)
inline
325  {
326  KeyPair pair = getKeyPair(filename);
327  X509Certificate cert = sslService.getPEMCertificate(getTempCertDir() + filename);
328 
329  boolean filesPresent = (pair != null) && (cert != null);
330 
331  return filesPresent;
332  }
SSLService sslService
Definition: ManageCertificateAction.java:93
X509Certificate getPEMCertificate(String fileName)
Definition: SSLService.java:69
String getTempCertDir()
Definition: ManageCertificateAction.java:342
KeyPair getKeyPair(String fileName)
Definition: ManageCertificateAction.java:256

◆ certUpload()

void org.gluu.oxtrust.action.ManageCertificateAction.certUpload ( FileUploadEvent  event)
inline
521  {
522  if (this.trustStoreCertificateUploadMarker == null) {
523  updateCert(event.getUploadedFile());
524  } else {
525  updateTrsutStoreCert(event.getUploadedFile());
526  }
527  }
void updateTrsutStoreCert(UploadedFile item)
Definition: ManageCertificateAction.java:547
void updateCert(UploadedFile item)
Definition: ManageCertificateAction.java:529
TrustStoreCertificate trustStoreCertificateUploadMarker
Definition: ManageCertificateAction.java:113

◆ compare()

boolean org.gluu.oxtrust.action.ManageCertificateAction.compare ( String  fileName)
inline
239  {
240  KeyPair pair = getKeyPair(fileName);
241  X509Certificate cert = sslService.getPEMCertificate(getTempCertDir() + fileName);
242 
243  boolean noFilesPresent = (pair == null) && (cert == null);
244 
245  boolean filesPresent = (pair != null) && (cert != null);
246  boolean filesValid = false;
247  if (filesPresent) {
248  filesValid = (pair.getPublic() != null) && (pair.getPublic().equals(cert.getPublicKey()));
249  }
250 
251  boolean compareResult = (noFilesPresent || (filesPresent && filesValid));
252  log.debug(fileName + " compare result: " + compareResult);
253  return compareResult;
254  }
SSLService sslService
Definition: ManageCertificateAction.java:93
X509Certificate getPEMCertificate(String fileName)
Definition: SSLService.java:69
String getTempCertDir()
Definition: ManageCertificateAction.java:342
Logger log
Definition: ManageCertificateAction.java:84
KeyPair getKeyPair(String fileName)
Definition: ManageCertificateAction.java:256

◆ generateCSR()

String org.gluu.oxtrust.action.ManageCertificateAction.generateCSR ( String  fileName) throws IOException
inline
204  {
205  if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
206  Security.addProvider(new BouncyCastleProvider());
207  }
208 
209  KeyPair pair = getKeyPair(fileName);
210  boolean result = false;
211  if (pair != null) {
212  String url = appConfiguration.getIdpUrl().replaceFirst(".*//", "");
213  String csrPrincipal = String.format("CN=%s", url);
214  X500Principal principal = new X500Principal(csrPrincipal);
215 
216  PKCS10CertificationRequest csr = null;
217  try {
218  csr = new PKCS10CertificationRequest("SHA1withRSA", principal, pair.getPublic(), null, pair.getPrivate());
219  } catch (GeneralSecurityException e) {
220  log.error(e.getMessage(), e);
221  return OxTrustConstants.RESULT_FAILURE;
222  }
223 
224  // Form download responce
225  StringBuilder response = new StringBuilder();
226 
227  response.append(BEGIN_CERT_REQ + "\n");
228  response.append(WordUtils.wrap(new String(Base64.encode(csr.getEncoded(ASN1Encoding.DER))), 64, "\n", true) + "\n");
229  response.append(END_CERT_REQ + "\n");
230 
231  FacesContext facesContext = FacesContext.getCurrentInstance();
232  result = ResponseHelper.downloadFile("csr.pem", OxTrustConstants.CONTENT_TYPE_TEXT_PLAIN, response.toString().getBytes(),
233  facesContext);
234  }
235 
236  return result ? OxTrustConstants.RESULT_SUCCESS : OxTrustConstants.RESULT_FAILURE;
237  }
AppConfiguration appConfiguration
Definition: ManageCertificateAction.java:96
Logger log
Definition: ManageCertificateAction.java:84
static final String END_CERT_REQ
Definition: ManageCertificateAction.java:79
KeyPair getKeyPair(String fileName)
Definition: ManageCertificateAction.java:256
static final String BEGIN_CERT_REQ
Definition: ManageCertificateAction.java:78

◆ getCert() [1/2]

void org.gluu.oxtrust.action.ManageCertificateAction.getCert ( String  fileName)
inline

Fills issuer and subject maps with data about currently selected certificate

164  {
165  X509Certificate cert = sslService.getPEMCertificate(getTempCertDir() + fileName);
166  loadCert(cert);
167  }
SSLService sslService
Definition: ManageCertificateAction.java:93
X509Certificate getPEMCertificate(String fileName)
Definition: SSLService.java:69
String getTempCertDir()
Definition: ManageCertificateAction.java:342
void loadCert(X509Certificate cert)
Definition: ManageCertificateAction.java:185

◆ getCert() [2/2]

void org.gluu.oxtrust.action.ManageCertificateAction.getCert ( TrustStoreCertificate  trustStoreCertificate)
inline

Fills issuer and subject maps with data about currently selected certificate

174  {
175  this.issuer = new HashMap<String, String>();
176  this.subject = new HashMap<String, String>();
177 
178  if (trustStoreCertificate != null) {
179  X509Certificate cert = sslService
180  .getPEMCertificate(new ByteArrayInputStream(trustStoreCertificate.getCertificate().getBytes()));
181  loadCert(cert);
182  }
183  }
SSLService sslService
Definition: ManageCertificateAction.java:93
HashMap< String, String > issuer
Definition: ManageCertificateAction.java:109
HashMap< String, String > subject
Definition: ManageCertificateAction.java:110
X509Certificate getPEMCertificate(String fileName)
Definition: SSLService.java:69
void loadCert(X509Certificate cert)
Definition: ManageCertificateAction.java:185

◆ getIdpCertFN()

String org.gluu.oxtrust.action.ManageCertificateAction.getIdpCertFN ( )
inline
334  {
335  return idpCertFN;
336  }
String idpCertFN
Definition: ManageCertificateAction.java:107

◆ getIssuer()

HashMap<String, String> org.gluu.oxtrust.action.ManageCertificateAction.getIssuer ( )
inline
346  {
347  return issuer;
348  }
HashMap< String, String > issuer
Definition: ManageCertificateAction.java:109

◆ getKeyPair()

KeyPair org.gluu.oxtrust.action.ManageCertificateAction.getKeyPair ( String  fileName)
inlineprivate
256  {
257  KeyPair pair = null;
258  JCERSAPrivateCrtKey privateKey = null;
259  PEMParser r = null;
260  FileReader fileReader = null;
261 
262  File keyFile = new File(getTempCertDir() + fileName.replace("crt", "key"));
263  if (keyFile.isFile()) {
264  try {
265  fileReader = new FileReader(keyFile);
266  r = new PEMParser(
267  fileReader /*
268  * , new PasswordFinder() { public char[]
269  * getPassword() { // Since keys are stored
270  * without a password this // function
271  * should not be called. return null; } }
272  */);
273 
274  Object keys = r.readObject();
275  if (keys == null) {
276  log.error(" Unable to read keys from: " + keyFile.getAbsolutePath());
277  return null;
278  }
279 
280  if (keys instanceof KeyPair) {
281  pair = (KeyPair) keys;
282  log.debug(keyFile.getAbsolutePath() + "contains KeyPair");
283  } else if (keys instanceof JCERSAPrivateCrtKey) {
284 
285  privateKey = (JCERSAPrivateCrtKey) keys;
286  log.debug(keyFile.getAbsolutePath() + "contains JCERSAPrivateCrtKey");
287  BigInteger exponent = privateKey.getPublicExponent();
288  BigInteger modulus = privateKey.getModulus();
289 
290  RSAPublicKeySpec publicKeySpec = new java.security.spec.RSAPublicKeySpec(modulus, exponent);
291  PublicKey publicKey = null;
292  try {
293  KeyFactory keyFactory = KeyFactory.getInstance("RSA");
294 
295  publicKey = keyFactory.generatePublic(publicKeySpec);
296  } catch (Exception e) {
297  e.printStackTrace();
298  }
299 
300  pair = new KeyPair(publicKey, privateKey);
301  } else {
302  log.error(keyFile.getAbsolutePath() + " Contains unsupported key type: " + keys.getClass().getName());
303  return null;
304  }
305 
306  } catch (IOException e) {
307  log.error(e.getMessage(), e);
308  return null;
309  } finally {
310  try {
311  r.close();
312  fileReader.close();
313  } catch (Exception e) {
314  log.error(e.getMessage(), e);
315  return null;
316  }
317  }
318  } else {
319  log.error("Key file does not exist : " + keyFile.getAbsolutePath());
320  }
321  log.debug("KeyPair successfully extracted from: " + keyFile.getAbsolutePath());
322  return pair;
323  }
String getTempCertDir()
Definition: ManageCertificateAction.java:342
Logger log
Definition: ManageCertificateAction.java:84

◆ getSubject()

HashMap<String, String> org.gluu.oxtrust.action.ManageCertificateAction.getSubject ( )
inline
350  {
351  return subject;
352  }
HashMap< String, String > subject
Definition: ManageCertificateAction.java:110

◆ getTempCertDir()

String org.gluu.oxtrust.action.ManageCertificateAction.getTempCertDir ( )
inline
342  {
343  return appConfiguration.getTempCertDir() + File.separator;
344  }
AppConfiguration appConfiguration
Definition: ManageCertificateAction.java:96

◆ getTomcatCertFN()

String org.gluu.oxtrust.action.ManageCertificateAction.getTomcatCertFN ( )
inline
338  {
339  return tomcatCertFN;
340  }
String tomcatCertFN
Definition: ManageCertificateAction.java:107

◆ getTrustStoreCertificates()

List<TrustStoreCertificate> org.gluu.oxtrust.action.ManageCertificateAction.getTrustStoreCertificates ( )
inline
616  {
617  return trustStoreCertificates;
618  }
List< TrustStoreCertificate > trustStoreCertificates
Definition: ManageCertificateAction.java:105

◆ getTrustStoreConfiguration()

TrustStoreConfiguration org.gluu.oxtrust.action.ManageCertificateAction.getTrustStoreConfiguration ( )
inline
612  {
614  }
TrustStoreConfiguration trustStoreConfiguration
Definition: ManageCertificateAction.java:104

◆ init()

String org.gluu.oxtrust.action.ManageCertificateAction.init ( )
inline
119  {
120  if (this.initialized) {
121  return OxTrustConstants.RESULT_SUCCESS;
122  }
123 
124  this.wereAnyChanges = false;
125 
127 
128  this.orgInumFN = StringHelper.removePunctuation(organizationService.getOrganizationInum());
129  this.tomcatCertFN = orgInumFN + "-java.crt";
130  this.idpCertFN = orgInumFN + "-shib.crt";
131 
132  try {
133  GluuAppliance appliance = applianceService.getAppliance();
134 
135  if (appliance == null) {
136  return OxTrustConstants.RESULT_FAILURE;
137  }
138 
139  trustStoreConfiguration = appliance.getTrustStoreConfiguration();
140  if (trustStoreConfiguration == null) {
141  trustStoreConfiguration = new TrustStoreConfiguration();
142  }
143 
144  trustStoreCertificates = appliance.getTrustStoreCertificates();
145  if (trustStoreCertificates == null) {
146  trustStoreCertificates = new ArrayList<TrustStoreCertificate>();
147  }
148  } catch (Exception ex) {
149  log.error("Failed to load appliance configuration", ex);
150 
151  return OxTrustConstants.RESULT_FAILURE;
152  }
153 
154  this.initialized = true;
155 
156  return OxTrustConstants.RESULT_SUCCESS;
157  }
TrustStoreConfiguration trustStoreConfiguration
Definition: ManageCertificateAction.java:104
GluuAppliance getAppliance(String[] returnAttributes)
Definition: ApplianceService.java:111
String getOrganizationInum()
Definition: OrganizationService.java:202
ApplianceService applianceService
Definition: ManageCertificateAction.java:99
boolean initialized
Definition: ManageCertificateAction.java:116
boolean prepareTempWorkspace()
Definition: ManageCertificateAction.java:364
boolean wereAnyChanges
Definition: ManageCertificateAction.java:117
String tomcatCertFN
Definition: ManageCertificateAction.java:107
String orgInumFN
Definition: ManageCertificateAction.java:107
String idpCertFN
Definition: ManageCertificateAction.java:107
Logger log
Definition: ManageCertificateAction.java:84
OrganizationService organizationService
Definition: ManageCertificateAction.java:87
List< TrustStoreCertificate > trustStoreCertificates
Definition: ManageCertificateAction.java:105
boolean certsMmanagePossible
Definition: ManageCertificateAction.java:115

◆ isCertsManagePossible()

boolean org.gluu.oxtrust.action.ManageCertificateAction.isCertsManagePossible ( )
inline
608  {
609  return certsMmanagePossible;
610  }
boolean certsMmanagePossible
Definition: ManageCertificateAction.java:115

◆ isInitialized()

boolean org.gluu.oxtrust.action.ManageCertificateAction.isInitialized ( )
inline
604  {
605  return initialized;
606  }
boolean initialized
Definition: ManageCertificateAction.java:116

◆ keyUpload()

void org.gluu.oxtrust.action.ManageCertificateAction.keyUpload ( FileUploadEvent  event)
inline
564  {
565  updateKey(event.getUploadedFile());
566  }
void updateKey(UploadedFile item)
Definition: ManageCertificateAction.java:568

◆ loadCert()

void org.gluu.oxtrust.action.ManageCertificateAction.loadCert ( X509Certificate  cert)
inlineprivate
185  {
186  if (cert != null) {
187  String issuerDN = cert.getIssuerX500Principal().getName();
188  String[] values = issuerDN.split("(?<!\\\\),");
189  for (String value : values) {
190  String[] keyValue = value.split("=");
191  issuer.put(keyValue[0], keyValue[1]);
192  }
193  String subjectDN = cert.getSubjectX500Principal().getName();
194  values = subjectDN.split("(?<!\\\\),");
195  for (String value : values) {
196  String[] keyValue = value.split("=");
197  subject.put(keyValue[0], keyValue[1]);
198  }
199  subject.put("validUntil", StringHelper.toString(cert.getNotAfter()));
200  subject.put("validAfter", StringHelper.toString(cert.getNotBefore()));
201  }
202  }
HashMap< String, String > issuer
Definition: ManageCertificateAction.java:109
HashMap< String, String > subject
Definition: ManageCertificateAction.java:110

◆ prepareTempWorkspace()

boolean org.gluu.oxtrust.action.ManageCertificateAction.prepareTempWorkspace ( )
inlineprivate
364  {
365  String tempDirFN = appConfiguration.getTempCertDir();
366  String dirFN = appConfiguration.getCertDir();
367  File certDir = new File(dirFN);
368  if (tempDirFN == null || dirFN == null || !certDir.isDirectory() || StringHelper.isEmpty(tempDirFN)) {
369 
370  return false;
371  } else {
372  File tempDir = new File(tempDirFN);
373  // If tempDir exists - empty it, if not - create. If exists, but
374  // isFile - write an error and return false.
375  if (tempDir.isDirectory()) {
376  File[] files = tempDir.listFiles();
377  for (File file : files) {
378  if (file.isFile()) {
379  file.delete();
380  }
381  }
382  } else {
383  if (tempDir.exists()) {
384  log.error("Temporary certifcates path exists but is not a directory");
385  return false;
386  } else {
387  tempDir.mkdirs();
388  }
389  }
390 
391  File[] files = certDir.listFiles();
392  for (File file : files) {
393  if (file.isFile()) {
394  try {
395  FileHelper.copy(file, new File(tempDirFN + File.separator + file.getName()));
396  } catch (IOException e) {
397  log.error("Unable to populate temp certs directory: ", e);
398  return false;
399  }
400  }
401  }
402  }
403 
404  return true;
405  }
AppConfiguration appConfiguration
Definition: ManageCertificateAction.java:96
Logger log
Definition: ManageCertificateAction.java:84

◆ removePublicCertificate()

void org.gluu.oxtrust.action.ManageCertificateAction.removePublicCertificate ( TrustStoreCertificate  removeTrustStoreCertificate)
inline
594  {
595  for (Iterator<TrustStoreCertificate> iterator = this.trustStoreCertificates.iterator(); iterator.hasNext();) {
596  TrustStoreCertificate trustStoreCertificate = iterator.next();
597  if (System.identityHashCode(removeTrustStoreCertificate) == System.identityHashCode(trustStoreCertificate)) {
598  iterator.remove();
599  return;
600  }
601  }
602  }
List< TrustStoreCertificate > trustStoreCertificates
Definition: ManageCertificateAction.java:105

◆ setUploadMarker() [1/2]

void org.gluu.oxtrust.action.ManageCertificateAction.setUploadMarker ( String  uploadMarker)
inline
354  {
355  this.uploadMarker = uploadMarker;
357  }
String uploadMarker
Definition: ManageCertificateAction.java:112
TrustStoreCertificate trustStoreCertificateUploadMarker
Definition: ManageCertificateAction.java:113

◆ setUploadMarker() [2/2]

void org.gluu.oxtrust.action.ManageCertificateAction.setUploadMarker ( TrustStoreCertificate  trustStoreCertificate)
inline
359  {
360  this.uploadMarker = null;
361  this.trustStoreCertificateUploadMarker = trustStoreCertificate;
362  }
String uploadMarker
Definition: ManageCertificateAction.java:112
TrustStoreCertificate trustStoreCertificateUploadMarker
Definition: ManageCertificateAction.java:113

◆ tirggerTrustStoreUpdate()

void org.gluu.oxtrust.action.ManageCertificateAction.tirggerTrustStoreUpdate ( )
inlineprivate
496  {
497  String certDirFileName = appConfiguration.getCertDir();
498  File certDir = new File(certDirFileName);
499 
500  if (this.wereAnyChanges) {
501  File pkcs12 = new File(certDir, orgInumFN + "-java.pkcs12");
502  File pem = new File(certDir, orgInumFN + "-java.pem");
503  File jks = new File(certDir, orgInumFN + "-java.jks");
504 
505  log.info("Deleting %s : %s", orgInumFN + "-java.pkcs12", pkcs12.delete());
506  log.info("Deleting %s : %s", orgInumFN + "-java.pem", pem.delete());
507  log.info("Deleting %s : %s", orgInumFN + "-java.jks", jks.delete());
508 
510 
511  facesMessages.add(FacesMessage.SEVERITY_WARN,
512  "Certificates were updated and appliance service will be restarted. Please log in again in 5 minutes.");
513 
514  this.wereAnyChanges = false;
515  }
516  }
ApplianceService applianceService
Definition: ManageCertificateAction.java:99
FacesMessages facesMessages
Definition: ManageCertificateAction.java:90
AppConfiguration appConfiguration
Definition: ManageCertificateAction.java:96
boolean wereAnyChanges
Definition: ManageCertificateAction.java:117
void restartServices()
Definition: ApplianceService.java:187
String orgInumFN
Definition: ManageCertificateAction.java:107
Logger log
Definition: ManageCertificateAction.java:84

◆ update()

String org.gluu.oxtrust.action.ManageCertificateAction.update ( )
inline
407  {
408  if (!isCertsManagePossible()) {
409  return OxTrustConstants.RESULT_FAILURE;
410  }
411 
412  boolean isUpdateTrustCertificates = updateTrustCertificates();
413  boolean isUpdatedCertificates = updateCertificates();
414  boolean result = isUpdateTrustCertificates && isUpdatedCertificates;
415 
416  if (result) {
418  }
419 
420  return result ? OxTrustConstants.RESULT_SUCCESS : OxTrustConstants.RESULT_FAILURE;
421  }
boolean updateTrustCertificates()
Definition: ManageCertificateAction.java:423
boolean isCertsManagePossible()
Definition: ManageCertificateAction.java:608
boolean updateCertificates()
Definition: ManageCertificateAction.java:464
void tirggerTrustStoreUpdate()
Definition: ManageCertificateAction.java:496

◆ updateCert()

void org.gluu.oxtrust.action.ManageCertificateAction.updateCert ( UploadedFile  item)
inlineprivate
529  {
530  InputStream is = null;
531  OutputStream os = null;
532  try {
533  is = item.getInputStream();
534  os = new FileOutputStream(getTempCertDir() + this.uploadMarker);
535  BufferedOutputStream bos = new BufferedOutputStream(os);
536 
537  IOUtils.copy(is, bos);
538  bos.flush();
539  } catch (IOException ex) {
540  log.error("Failed to upload certicicate", ex);
541  } finally {
542  IOUtils.closeQuietly(is);
543  IOUtils.closeQuietly(os);
544  }
545  }
String uploadMarker
Definition: ManageCertificateAction.java:112
String getTempCertDir()
Definition: ManageCertificateAction.java:342
Logger log
Definition: ManageCertificateAction.java:84

◆ updateCertificates()

boolean org.gluu.oxtrust.action.ManageCertificateAction.updateCertificates ( )
inlineprivate

Updates certificates from temporary working directory to production and restarts services.

戻り値
true if update was successful. false if update was aborted due to some error (perhaps permissions issue.)
464  {
465  if (!compare(tomcatCertFN) || !compare(idpCertFN)) {
466  facesMessages.add(FacesMessage.SEVERITY_ERROR, "Certificates and private keys should match. Certificate update aborted.");
467  return false;
468  }
469 
470  String tempDirFN = appConfiguration.getTempCertDir();
471  String dirFN = appConfiguration.getCertDir();
472  File certDir = new File(dirFN);
473  File tempDir = new File(tempDirFN);
474  if (tempDirFN == null || dirFN == null || !certDir.isDirectory() || !tempDir.isDirectory()) {
475  facesMessages.add(FacesMessage.SEVERITY_ERROR, "Certificate update aborted due to filesystem error");
476  return false;
477  } else {
478  File[] files = tempDir.listFiles();
479  for (File file : files) {
480  try {
481  if (file.isFile() && !FileUtils.contentEquals(file, new File(dirFN + File.separator + file.getName()))) {
482  FileHelper.copy(file, new File(dirFN + File.separator + file.getName()));
483  this.wereAnyChanges = true;
484  }
485  } catch (IOException e) {
486  facesMessages.add(FacesMessage.SEVERITY_FATAL,
487  "Certificate update failed. Certificates may have been corrupted. Please contact a Gluu administrator for help.");
488  log.error("Error occured on certificates update:", e);
489  }
490  }
491  }
492 
493  return true;
494  }
FacesMessages facesMessages
Definition: ManageCertificateAction.java:90
AppConfiguration appConfiguration
Definition: ManageCertificateAction.java:96
boolean wereAnyChanges
Definition: ManageCertificateAction.java:117
String tomcatCertFN
Definition: ManageCertificateAction.java:107
String idpCertFN
Definition: ManageCertificateAction.java:107
Logger log
Definition: ManageCertificateAction.java:84
boolean compare(String fileName)
Definition: ManageCertificateAction.java:239

◆ updateKey()

void org.gluu.oxtrust.action.ManageCertificateAction.updateKey ( UploadedFile  item)
inlineprivate
568  {
569  InputStream is = null;
570  OutputStream os = null;
571  try {
572  is = item.getInputStream();
573  os = new FileOutputStream(getTempCertDir() + this.uploadMarker.replace("crt", "key"));
574  BufferedOutputStream bos = new BufferedOutputStream(os);
575 
576  IOUtils.copy(is, bos);
577  bos.flush();
578  } catch (IOException ex) {
579  log.error("Failed to upload key", ex);
580  } finally {
581  IOUtils.closeQuietly(is);
582  IOUtils.closeQuietly(os);
583  }
584  }
String uploadMarker
Definition: ManageCertificateAction.java:112
String getTempCertDir()
Definition: ManageCertificateAction.java:342
Logger log
Definition: ManageCertificateAction.java:84

◆ updateTrsutStoreCert()

void org.gluu.oxtrust.action.ManageCertificateAction.updateTrsutStoreCert ( UploadedFile  item)
inlineprivate
547  {
548  InputStream is = null;
549  try {
550  is = item.getInputStream();
551  String certificate = IOUtils.toString(is);
553 
556 
557  } catch (IOException ex) {
558  log.error("Failed to upload key", ex);
559  } finally {
560  IOUtils.closeQuietly(is);
561  }
562  }
Identity identity
Definition: ManageCertificateAction.java:102
void setAddedBy(String addedBy)
Definition: TrustStoreCertificate.java:69
GluuCustomPerson getUser()
Definition: Identity.java:39
Logger log
Definition: ManageCertificateAction.java:84
void setCertificate(String certificate)
Definition: TrustStoreCertificate.java:53
TrustStoreCertificate trustStoreCertificateUploadMarker
Definition: ManageCertificateAction.java:113
void setAddedAt(Date addedAt)
Definition: TrustStoreCertificate.java:77

◆ updateTrustCertificates()

boolean org.gluu.oxtrust.action.ManageCertificateAction.updateTrustCertificates ( )
inlineprivate
423  {
424  try {
425  // Reload entry to include latest changes
426  GluuAppliance tmpAppliance = applianceService.getAppliance();
427 
428  TrustStoreConfiguration currTrustStoreConfiguration = tmpAppliance.getTrustStoreConfiguration();
429  List<TrustStoreCertificate> currTrustStoreCertificates = tmpAppliance.getTrustStoreCertificates();
430  if (currTrustStoreCertificates == null) {
431  currTrustStoreCertificates = new ArrayList<TrustStoreCertificate>(0);
432  }
433 
434  if (!trustStoreConfiguration.equals(currTrustStoreConfiguration)
435  || !trustStoreCertificates.equals(currTrustStoreCertificates)) {
436  this.wereAnyChanges = true;
437  }
438 
439  tmpAppliance.setTrustStoreConfiguration(trustStoreConfiguration);
440 
441  if (trustStoreCertificates.size() == 0) {
442  tmpAppliance.setTrustStoreCertificates(null);
443  } else {
444  tmpAppliance.setTrustStoreCertificates(trustStoreCertificates);
445  }
446 
447  applianceService.updateAppliance(tmpAppliance);
448  } catch (BasePersistenceException ex) {
449  log.error("Failed to update appliance configuration", ex);
450  facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update appliance");
451  return false;
452  }
453 
454  return true;
455  }
TrustStoreConfiguration trustStoreConfiguration
Definition: ManageCertificateAction.java:104
void updateAppliance(GluuAppliance appliance)
Definition: ApplianceService.java:75
GluuAppliance getAppliance(String[] returnAttributes)
Definition: ApplianceService.java:111
ApplianceService applianceService
Definition: ManageCertificateAction.java:99
FacesMessages facesMessages
Definition: ManageCertificateAction.java:90
TrustStoreConfiguration getTrustStoreConfiguration()
Definition: GluuAppliance.java:574
boolean wereAnyChanges
Definition: ManageCertificateAction.java:117
Logger log
Definition: ManageCertificateAction.java:84
boolean equals(Object obj)
Definition: TrustStoreConfiguration.java:46
List< TrustStoreCertificate > trustStoreCertificates
Definition: ManageCertificateAction.java:105

メンバ詳解

◆ appConfiguration

AppConfiguration org.gluu.oxtrust.action.ManageCertificateAction.appConfiguration
private

◆ applianceService

ApplianceService org.gluu.oxtrust.action.ManageCertificateAction.applianceService
private

◆ BEGIN_CERT_REQ

final String org.gluu.oxtrust.action.ManageCertificateAction.BEGIN_CERT_REQ = "-----BEGIN CERTIFICATE REQUEST-----"
static

◆ certsMmanagePossible

boolean org.gluu.oxtrust.action.ManageCertificateAction.certsMmanagePossible
private

◆ END_CERT_REQ

final String org.gluu.oxtrust.action.ManageCertificateAction.END_CERT_REQ = "-----END CERTIFICATE REQUEST-----"
static

◆ facesMessages

FacesMessages org.gluu.oxtrust.action.ManageCertificateAction.facesMessages
private

◆ identity

Identity org.gluu.oxtrust.action.ManageCertificateAction.identity
private

◆ idpCertFN

String org.gluu.oxtrust.action.ManageCertificateAction.idpCertFN
package

◆ initialized

boolean org.gluu.oxtrust.action.ManageCertificateAction.initialized
private

◆ issuer

HashMap<String, String> org.gluu.oxtrust.action.ManageCertificateAction.issuer
private

◆ log

Logger org.gluu.oxtrust.action.ManageCertificateAction.log
private

◆ organizationService

OrganizationService org.gluu.oxtrust.action.ManageCertificateAction.organizationService
private

◆ orgInumFN

String org.gluu.oxtrust.action.ManageCertificateAction.orgInumFN
private

◆ serialVersionUID

final long org.gluu.oxtrust.action.ManageCertificateAction.serialVersionUID = 4012709440384265524L
staticprivate

◆ sslService

SSLService org.gluu.oxtrust.action.ManageCertificateAction.sslService
private

◆ subject

HashMap<String, String> org.gluu.oxtrust.action.ManageCertificateAction.subject
private

◆ tomcatCertFN

String org.gluu.oxtrust.action.ManageCertificateAction.tomcatCertFN
package

◆ trustStoreCertificates

List<TrustStoreCertificate> org.gluu.oxtrust.action.ManageCertificateAction.trustStoreCertificates
private

◆ trustStoreCertificateUploadMarker

TrustStoreCertificate org.gluu.oxtrust.action.ManageCertificateAction.trustStoreCertificateUploadMarker
private

◆ trustStoreConfiguration

TrustStoreConfiguration org.gluu.oxtrust.action.ManageCertificateAction.trustStoreConfiguration
private

◆ uploadMarker

String org.gluu.oxtrust.action.ManageCertificateAction.uploadMarker
private

◆ wereAnyChanges

boolean org.gluu.oxtrust.action.ManageCertificateAction.wereAnyChanges
private

このクラス詳解は次のファイルから抽出されました: