Examples of SecurityConfigException


Examples of org.wso2.carbon.security.SecurityConfigException

  public void removeCertFromStore(String alias, String keyStoreName)
      throws SecurityConfigException {
    try {
      if (keyStoreName == null) {
        throw new SecurityConfigException("Key Store name can't be null");
      }

      KeyStoreManager keyMan = KeyStoreManager.getInstance((UserRegistry)registry);
      KeyStore ks = keyMan.getKeyStore(keyStoreName);

      if (ks.getCertificate(alias) == null) {
        return;
      }

      ks.deleteEntry(alias);
      keyMan.updateKeyStore(keyStoreName, ks);
    } catch (SecurityConfigException e) {
      throw e;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new SecurityConfigException(e.getMessage(), e);
    }
  }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }

        } catch (Exception e) {
            log.error("Error while adding a trusted service", e);
            throw new SecurityConfigException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

      names = lst.toArray(new String[lst.size()]);
    } catch (SecurityConfigException e) {
      throw e;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new SecurityConfigException(e.getMessage(), e);
    }

    return names;
  }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }

        } catch (Exception e) {
            log.error("Error while removing a trusted service", e);
            throw new SecurityConfigException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

        alias = cnStr.substring(3).toLowerCase();
        break;
      }
    }
    if (alias == null) {
      throw new SecurityConfigException("Null Alias");
    }
    return alias;
  }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }

        } catch (Exception e) {
            log.error("Error setting proof key type", e);
            throw new SecurityConfigException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

        privateKeyPassowrd = serverConfig
            .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIVATE_KEY_PASSWORD);
      } else {
        String path = SecurityConstants.KEY_STORES + "/" + keyStoreName;
        if (!registry.resourceExists(path)) {
          throw new SecurityConfigException("Key Store not found");
        }
        Resource resource = registry.get(path);
        KeyStoreManager manager = KeyStoreManager.getInstance((UserRegistry)registry);
        keyStore = manager.getKeyStore(keyStoreName);
        keyStoreType = resource.getProperty(SecurityConstants.PROP_TYPE);

        String encpass = resource.getProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS);

        CryptoUtil util = CryptoUtil.getDefaultCryptoUtil();
        privateKeyPassowrd = new String(util.base64DecodeAndDecrypt(encpass));

      }
      // Fill the information about the certificates
      Enumeration<String> aliases = keyStore.aliases();
      List<org.wso2.carbon.security.keystore.service.CertData> certDataList = new ArrayList<CertData>();
      Format formatter = new SimpleDateFormat("dd/MM/yyyy");

      while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        if (keyStore.isCertificateEntry(alias)) {
          X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias);
          certDataList.add(fillCertData(cert, alias, formatter));
        }
      }

      // Create a cert array
      CertData[] certs = certDataList.toArray(new CertData[certDataList.size()]);

      // Create a KeyStoreData bean, set the name and fill in the cert information
      KeyStoreData keyStoreData = new KeyStoreData();
      keyStoreData.setKeyStoreName(keyStoreName);
      keyStoreData.setCerts(certs);
      keyStoreData.setKeyStoreType(keyStoreType);

      aliases = keyStore.aliases();
      while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        // There be only one entry in WSAS related keystores
        if (keyStore.isKeyEntry(alias)) {
          X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias);
          keyStoreData.setKey(fillCertData(cert, alias, formatter));

          PrivateKey key = (PrivateKey) keyStore.getKey(alias, privateKeyPassowrd
              .toCharArray());
          String pemKey;
          pemKey = "-----BEGIN PRIVATE KEY-----\n";
          pemKey += Base64.encode(key.getEncoded());
          pemKey += "\n-----END PRIVATE KEY-----";
          keyStoreData.setKeyValue(pemKey);
          break;

        }
      }
      return keyStoreData;
    } catch (Exception e) {
      String msg = "Error has encounted while loading the keystore to the given keystore name "
          + keyStoreName;
      log.error(msg, e);
      throw new SecurityConfigException(msg);
    }

  }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

                    serviceBag.add(data);
                }
                return (TrustedServiceData[]) serviceBag.toArray(new TrustedServiceData[serviceBag
                        .size()]);
            } else {
                throw new SecurityConfigException("missing parameter : "
                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }
        } catch (Exception e) {
            log.error("Error while retrieving trusted services", e);
            throw new SecurityConfigException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

        }
      }
    } catch (Exception e) {
      String msg = "Error has encounted while loading the key for the given alias " + alias;
      log.error(msg, e);
      throw new SecurityConfigException(msg);
    }
    return null;
  }
View Full Code Here

Examples of org.wso2.carbon.security.SecurityConfigException

                OMElement samlConfigElem = origParam.getParameterElement().getFirstChildWithName(
                        SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG);
                SAMLTokenIssuerConfig samlConfig = new SAMLTokenIssuerConfig(samlConfigElem);
                return samlConfig.getProofKeyType();
            } else {
                throw new SecurityConfigException("missing parameter : "
                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }
        } catch (Exception e) {
            log.error("Error while retrieving proof key type", e);
            throw new SecurityConfigException(e.getMessage(), e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.