Package org.wso2.carbon.core.util

Examples of org.wso2.carbon.core.util.KeyStoreManager


        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here


            + RegistryResources.SERVICES + axisService.getName();

            Resource serviceResource = registry.get(servicePath);
            Association[] assoc = registry.getAssociations(servicePath, RegistryResources.Associations.PRIVATE_KEYSTORE);
           
            KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(null);
           
            KeyStore keyStore = null;
            if(assoc.length < 1){

                boolean httpsEnabled = false;
                Association[] associations =
                    registry.getAssociations(servicePath, RegistryResources.Associations.EXPOSED_TRANSPORTS);
                for (Association association : associations) {
                    Resource resource = registry.get(association.getDestinationPath());
                    String transportProtocol = resource.getProperty(RegistryResources.Transports.PROTOCOL_NAME);
                    if(transportProtocol.equals("https")){
                        httpsEnabled = true;
                        break;
                    }
                    resource.discard();
                }
               
                if (httpsEnabled ||Boolean.valueOf(serviceResource.getProperty(RegistryResources.ServiceProperties.EXPOSED_ON_ALL_TANSPORTS))) {
                    keyStore = keyStoreManager.getPrimaryKeyStore();
                }
            } else {
                KeyStore ks = null;
                String kspath = assoc[0].getDestinationPath();
                if(kspath.equals(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)){
                    keyStore = keyStoreManager.getPrimaryKeyStore();
                }else{
                    String keyStoreName = kspath.substring(kspath.lastIndexOf("/")+1);
                    keyStore = keyStoreManager.getKeyStore(keyStoreName);
                }
            }
            serviceResource.discard();

            String alias = null;
View Full Code Here

            new Integer(tenantId));
      }

            this.properties = prop;
           
            KeyStoreManager keyMan = KeyStoreManager.getInstance((UserRegistry)registry);
            String ksId = this.properties.getProperty(PROP_ID_PRIVATE_STORE);
            if(ksId != null){
                this.keystore = keyMan.getKeyStore(ksId);
            }
           
            // Get other keystores if available
            String trustStoreIds = this.properties.getProperty(PROP_ID_TRUST_STORES);
            if (trustStoreIds != null && trustStoreIds.trim().length() != 0) {
                String[] ids = trustStoreIds.trim().split(",");
                this.trustStores = new ArrayList(ids.length);
                for (int i = 0; i < ids.length; i++) {
                    String id = ids[i];
                    KeyStore tstks = keyMan.getKeyStore(id);
                    this.trustStores.add(i, tstks);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

  private SignKeyDataHolder() throws IdentityProviderException {
    // do once - because this is a expensive operation
    String keyAlias = null;
    KeyStoreAdmin keyAdmin = null;
    KeyStoreManager keyMan = null;
    Certificate[] certificates = null;

    try {

      keyAlias = ServerConfiguration.getInstance().getFirstProperty(
          "Security.KeyStore.KeyAlias");

      keyAdmin = new KeyStoreAdmin(IdentityTenantUtil.getRegistry(null,null));
      keyMan = KeyStoreManager.getInstance(null);

      issuerPK = (PrivateKey) keyAdmin.getPrivateKey(keyAlias);;
      certificates = keyMan.getPrimaryKeyStore().getCertificateChain(keyAlias);

      issuerCerts = new X509Certificate[certificates.length];

      int i = 0;
      for (Certificate certificate : certificates) {
View Full Code Here

        String password = null;
        int tenantId = ((UserRegistry)registry).getTenantId();
        UserRegistry govRegistry = SecurityServiceHolder.getRegistryService().
                getGovernanceSystemRegistry(tenantId);
        try {
            KeyStoreManager keyMan = KeyStoreManager.getInstance(govRegistry);
            if (govRegistry.resourceExists(SecurityConstants.KEY_STORES)) {
                Collection collection = (Collection) govRegistry.get(SecurityConstants.KEY_STORES);
                String[] ks = collection.getChildren();

                for (int i = 0; i < ks.length; i++) {

                    String fullname = ks[i];
                    //get the primary keystore, only if it is super tenant.
                    if (tenantId == 0 && fullname
                            .equals(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
                        KeyStore store = keyMan.getPrimaryKeyStore();
                        if (store.containsAlias(username)) {
                            password = keyMan.getPrimaryPrivateKeyPasssword();
                            break;
                        }
                    } else {
                        String name = fullname.substring(fullname.lastIndexOf("/") + 1);
                        KeyStore store = keyMan.getKeyStore(name);
                        if (store.containsAlias(username)) {
                            Resource resource = (Resource) govRegistry.get(ks[i]);
                            CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil();
                            String encryptedPassword = resource
                                    .getProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS);
View Full Code Here

    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);

      byte[] bytes = Base64.decode(certData);
      CertificateFactory factory = CertificateFactory.getInstance("X.509");
      X509Certificate cert;
            try {
                cert = (X509Certificate) factory
                    .generateCertificate(new ByteArrayInputStream(bytes));
            } catch (CertificateException e) {
                log.error(e.getMessage(), e);
                throw new SecurityConfigException("Invalid format of the provided certificate file");
            }

      if (ks.getCertificateAlias(cert) != null) {
        // We already have this certificate in the key store - ignore
        // adding it twice
        return;
      }

      // String alias = this.getAlias(cert);
      ks.setCertificateEntry(fileName, cert);

      keyMan.updateKeyStore(keyStoreName, ks);

    } catch (SecurityConfigException e) {
      throw e;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
View Full Code Here

    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);

      byte[] bytes = Base64.decode(certData);
      CertificateFactory factory = CertificateFactory.getInstance("X.509");
      X509Certificate cert;
            try {
                cert = (X509Certificate) factory
                    .generateCertificate(new ByteArrayInputStream(bytes));
            } catch (Exception e) {
                throw new SecurityConfigException("Invalid format of the provided certificate file");
            }

      if (ks.getCertificateAlias(cert) != null) {
        // We already have this certificate in the key store - ignore
        // adding it twice
        return null;
      }
      alias = cert.getSubjectDN().getName();
      // String alias = this.getAlias(cert);
      ks.setCertificateEntry(alias, cert);

      keyMan.updateKeyStore(keyStoreName, ks);

      return alias;

    } catch (SecurityConfigException e) {
      throw e;
View Full Code Here

    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

    try {
      if (keyStoreName == null) {
        throw new Exception("keystore name cannot be null");
      }

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

      Enumeration<String> enm = ks.aliases();
      List<String> lst = new ArrayList<String>();
      while (enm.hasMoreElements()) {
        lst.add(enm.nextElement());
View Full Code Here

      KeyStore keyStore;
      String keyStoreType;
      String privateKeyPassowrd;
      if (KeyStoreUtil.isPrimaryStore(keyStoreName)) {
        KeyStoreManager keyMan = KeyStoreManager.getInstance((UserRegistry)registry);
        keyStore = keyMan.getPrimaryKeyStore();
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        keyStoreType = serverConfig
            .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIMARY_KEYSTORE_TYPE);
        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();
View Full Code Here

TOP

Related Classes of org.wso2.carbon.core.util.KeyStoreManager

Copyright © 2018 www.massapicom. 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.