Repository: stratos Updated Branches: refs/heads/master 2ac3e6852 -> ad2e7d531
Using Carbon TenantMgtListener and removing unused stratos.keystore component Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ad2e7d53 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ad2e7d53 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ad2e7d53 Branch: refs/heads/master Commit: ad2e7d531d0fb39e812f16ab509e3470304ab1c1 Parents: 2ac3e68 Author: lasinducharith <[email protected]> Authored: Tue Jul 28 15:11:26 2015 +0530 Committer: lasinducharith <[email protected]> Committed: Tue Jul 28 15:11:26 2015 +0530 ---------------------------------------------------------------------- .../common/listeners/TenantMgtListener.java | 45 ---- .../org.apache.stratos.keystore.mgt/pom.xml | 127 ---------- .../stratos/keystore/mgt/KeyStoreGenerator.java | 249 ------------------- .../keystore/mgt/KeyStoreMgtException.java | 40 --- .../keystore/mgt/KeystoreTenantMgtListener.java | 86 ------- .../internal/KeyStoreMgtServiceComponent.java | 88 ------- .../keystore/mgt/util/RealmServiceHolder.java | 34 --- .../mgt/util/RegistryServiceHolder.java | 34 --- .../StratosManagerServiceComponent.java | 4 +- .../publisher/TenantEventPublisher.java | 34 +-- .../user/management/TenantUserRoleManager.java | 31 +-- .../rest/endpoint/api/StratosApiV41Utils.java | 9 - components/pom.xml | 1 - .../pom.xml | 6 - .../distribution/src/main/license/LICENSE | 1 - 15 files changed, 25 insertions(+), 764 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/listeners/TenantMgtListener.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/listeners/TenantMgtListener.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/listeners/TenantMgtListener.java deleted file mode 100644 index 093e5aa..0000000 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/listeners/TenantMgtListener.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.common.listeners; - - -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.exception.ApacheStratosException; - -public interface TenantMgtListener { - public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException; - - public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException; - - public void onTenantDelete(int tenantId); - - public void onTenantRename(int tenantId, String oldDomainName, - String newDomainName) throws ApacheStratosException; - - public void onTenantInitialActivation(int tenantId) throws ApacheStratosException; - - public void onTenantActivation(int tenantId) throws ApacheStratosException; - - public void onTenantDeactivation(int tenantId) throws ApacheStratosException; - - public void onSubscriptionPlanChange(int tenentId, String oldPlan, - String newPlan) throws ApacheStratosException; - - public int getListenerOrder(); -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/pom.xml b/components/org.apache.stratos.keystore.mgt/pom.xml deleted file mode 100644 index aa56290..0000000 --- a/components/org.apache.stratos.keystore.mgt/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF licenses this file - # to you under the Apache License, Version 2.0 (the - # "License"); you may not use this file except in compliance - # with the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, - # software distributed under the License is distributed on an - # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - # KIND, either express or implied. See the License for the - # specific language governing permissions and limitations - # under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>org.apache.stratos</groupId> - <artifactId>stratos-components-parent</artifactId> - <version>4.1.1-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.keystore.mgt</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Keystore Generation and Management</name> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <Private-Package> - org.apache.stratos.keystore.mgt.internal - </Private-Package> - <Export-Package> - !org.apache.stratos.keystore.mgt.internal, - org.apache.stratos.keystore.mgt.*, - </Export-Package> - <Import-Package> - javax.servlet;version="${imp.pkg.version.javax.servlet}", - javax.servlet.http;version="${imp.pkg.version.javax.servlet}", - org.wso2.carbon.security.*, - org.apache.lucene.*, - *;resolution:=optional - </Import-Package> - <Embed-Dependency> - bcprov-jdk15|naming-factory|naming-resources|commons-collections;scope=compile|runtime;inline=false - </Embed-Dependency> - <DynamicImport-Package>*</DynamicImport-Package> - </instructions> - </configuration> - </plugin> - - </plugins> - </build> - - <dependencies> - - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>commons-codec.wso2</groupId> - <artifactId>commons-codec</artifactId> - <version>1.4.0.wso2v1</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.equinox</groupId> - <artifactId>javax.servlet</artifactId> - <version>${version.javax.servlet}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.axis2.wso2</groupId> - <artifactId>axis2</artifactId> - </dependency> - <dependency> - <groupId>org.apache.ws.commons.axiom.wso2</groupId> - <artifactId>axiom</artifactId> - <version>${axiom.wso2.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>bouncycastle</groupId> - <artifactId>bcprov-jdk15</artifactId> - <version>132</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.security.mgt</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - </dependencies> - - <properties> - <version.javax.servlet>3.0.0.v201112011016</version.javax.servlet> - </properties> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreGenerator.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreGenerator.java b/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreGenerator.java deleted file mode 100644 index 76f5259..0000000 --- a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreGenerator.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.keystore.mgt; - -import org.apache.axiom.om.util.UUIDGenerator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.bouncycastle.jce.X509Principal; -import org.bouncycastle.jce.X509V3CertificateGenerator; -import org.wso2.carbon.core.RegistryResources; -import org.wso2.carbon.core.util.CryptoUtil; -import org.apache.stratos.keystore.mgt.util.RealmServiceHolder; -import org.apache.stratos.keystore.mgt.util.RegistryServiceHolder; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.security.SecurityConstants; -import org.wso2.carbon.security.keystore.KeyStoreAdmin; -import org.wso2.carbon.user.core.service.RealmService; - -import java.io.ByteArrayOutputStream; -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.KeyStore; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.Date; - -/** - * This class is used to generate a key store for a tenant and store it in the governance registry. - */ -public class KeyStoreGenerator { - - private static Log log = LogFactory.getLog(KeyStoreGenerator.class); - private UserRegistry govRegistry; - private int tenantId; - private String tenantDomain; - private String password; - - - public KeyStoreGenerator(int tenantId) throws KeyStoreMgtException { - try { - this.tenantId = tenantId; - this.tenantDomain = getTenantDomainName(); - this.govRegistry = RegistryServiceHolder.getRegistryService(). - getGovernanceSystemRegistry(tenantId); - if(govRegistry == null){ - log.error("Governance registry instance is null"); - throw new KeyStoreMgtException("Governance registry instance is null"); - } - } catch (RegistryException e) { - String errorMsg = "Error while obtaining the governance registry for tenant : " + - tenantId; - log.error(errorMsg, e); - throw new KeyStoreMgtException(errorMsg, e); - } - } - - - /** - * This method first generates the keystore, then persist it in the gov.registry of that tenant - * - * @throws KeyStoreMgtException Error when generating or storing the keystore - */ - public void generateKeyStore() throws KeyStoreMgtException { - try { - password = generatePassword(); - KeyStore keyStore = KeyStore.getInstance("JKS"); - keyStore.load(null, password.toCharArray()); - X509Certificate pubCert = generateKeyPair(keyStore); - persistKeyStore(keyStore, pubCert); - } catch (Exception e) { - String msg = "Error while instantiating a keystore"; - log.error(msg, e); - throw new KeyStoreMgtException(msg, e); - } - } - - /** - * This method checks the existance of a keystore - * - * @return - * @throws KeyStoreMgtException - */ - public boolean isKeyStoreExists() throws KeyStoreMgtException { - boolean isKeyStoreExists = false; - String keyStoreName = generateKSNameFromDomainName(); - try { - isKeyStoreExists = govRegistry.resourceExists(RegistryResources.SecurityManagement.KEY_STORES + "/" + keyStoreName); - } catch (RegistryException e) { - String msg = "Error while checking the existance of keystore"; - log.error(msg, e); - throw new KeyStoreMgtException(msg, e); - } - return isKeyStoreExists; - } - - /** - * This method generates the keypair and stores it in the keystore - * - * @param keyStore A keystore instance - * @return Generated public key for the tenant - * @throws KeyStoreMgtException Error when generating key pair - */ - private X509Certificate generateKeyPair(KeyStore keyStore) throws KeyStoreMgtException { - try { - CryptoUtil.getDefaultCryptoUtil(); - //generate key pair - KeyPairGenerator keyPairGenerator = null; - keyPairGenerator = KeyPairGenerator.getInstance("RSA"); - keyPairGenerator.initialize(1024); - KeyPair keyPair = keyPairGenerator.generateKeyPair(); - - // Common Name and alias for the generated certificate - String commonName = "CN=" + tenantDomain + ", OU=None, O=None L=None, C=None"; - - //generate certificates - X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator(); - v3CertGen.setSerialNumber(BigInteger.valueOf(new SecureRandom().nextInt())); - v3CertGen.setIssuerDN(new X509Principal(commonName)); - v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30)); - v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365 * 10))); - v3CertGen.setSubjectDN(new X509Principal(commonName)); - v3CertGen.setPublicKey(keyPair.getPublic()); - v3CertGen.setSignatureAlgorithm("MD5WithRSAEncryption"); - X509Certificate PKCertificate = v3CertGen.generateX509Certificate(keyPair.getPrivate()); - - //add private key to KS - keyStore.setKeyEntry(tenantDomain, keyPair.getPrivate(), password.toCharArray(), - new java.security.cert.Certificate[]{PKCertificate}); - return PKCertificate; - } catch (Exception ex) { - String msg = "Error while generating the certificate for tenant :" + - tenantDomain + "."; - log.error(msg, ex); - throw new KeyStoreMgtException(msg, ex); - } - - } - - /** - * Persist the keystore in the gov.registry - * - * @param keyStore created Keystore of the tenant - * @param PKCertificate pub. key of the tenant - * @throws KeyStoreMgtException Exception when storing the keystore in the registry - */ - private void persistKeyStore(KeyStore keyStore, X509Certificate PKCertificate) - throws KeyStoreMgtException { - try { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - keyStore.store(outputStream, password.toCharArray()); - outputStream.flush(); - outputStream.close(); - - String keyStoreName = generateKSNameFromDomainName(); - // Use the keystore using the keystore admin - KeyStoreAdmin keystoreAdmin = new KeyStoreAdmin(tenantId, govRegistry); - keystoreAdmin.addKeyStore(outputStream.toByteArray(), keyStoreName, - password, " ", "JKS", password); - - //Create the pub. key resource - Resource pubKeyResource = govRegistry.newResource(); - pubKeyResource.setContent(PKCertificate.getEncoded()); - pubKeyResource.addProperty(SecurityConstants.PROP_TENANT_PUB_KEY_FILE_NAME_APPENDER, - generatePubKeyFileNameAppender()); - - govRegistry.put(RegistryResources.SecurityManagement.TENANT_PUBKEY_RESOURCE, pubKeyResource); - - //associate the public key with the keystore - govRegistry.addAssociation(RegistryResources.SecurityManagement.KEY_STORES + "/" + keyStoreName, - RegistryResources.SecurityManagement.TENANT_PUBKEY_RESOURCE, - SecurityConstants.ASSOCIATION_TENANT_KS_PUB_KEY); - - } catch (RegistryException e) { - String msg = "Error when writing the keystore/pub.cert to registry"; - log.error(msg, e); - throw new KeyStoreMgtException(msg, e); - } - catch (Exception e) { - String msg = "Error when processing keystore/pub. cert to be stored in registry"; - log.error(msg, e); - throw new KeyStoreMgtException(msg, e); - } - } - - /** - * This method is used to generate a random password for the generated keystore - * - * @return generated password - */ - private String generatePassword() { - SecureRandom random = new SecureRandom(); - String randString = new BigInteger(130, random).toString(12); - return randString.substring(randString.length() - 10, randString.length()); - } - - /** - * This method is used to generate a file name appender for the pub. cert, e.g. - * example-com-343743.cert - * @return generated string to be used as a file name appender - */ - private String generatePubKeyFileNameAppender(){ - String uuid = UUIDGenerator.getUUID(); - return uuid.substring(uuid.length() - 6, uuid.length()-1); - } - - /** - * This method generates the key store file name from the Domain Name - * @return - */ - private String generateKSNameFromDomainName(){ - String ksName = tenantDomain.trim().replace(".", "-"); - return (ksName + ".jks" ); - } - - private String getTenantDomainName() throws KeyStoreMgtException { - RealmService realmService = RealmServiceHolder.getRealmService(); - if (realmService == null) { - String msg = "Error in getting the domain name, realm service is null."; - log.error(msg); - throw new KeyStoreMgtException(msg); - } - try { - return realmService.getTenantManager().getDomain(tenantId); - } catch (org.wso2.carbon.user.api.UserStoreException e) { - String msg = "Error in getting the domain name for the tenant id: " + tenantId; - log.error(msg, e); - throw new KeyStoreMgtException(msg, e); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreMgtException.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreMgtException.java b/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreMgtException.java deleted file mode 100644 index 2cc47d2..0000000 --- a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeyStoreMgtException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.keystore.mgt; - -/** - * This class is used to wrap the exceptions thrown from stratos keystore mgt component. - */ -public class KeyStoreMgtException extends Exception { - public KeyStoreMgtException() { - } - - public KeyStoreMgtException(String message) { - super(message); - } - - public KeyStoreMgtException(String message, Throwable cause) { - super(message, cause); - } - - public KeyStoreMgtException(Throwable cause) { - super(cause); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeystoreTenantMgtListener.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeystoreTenantMgtListener.java b/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeystoreTenantMgtListener.java deleted file mode 100644 index c7fb043..0000000 --- a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/KeystoreTenantMgtListener.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.keystore.mgt; - -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.exception.ApacheStratosException; -import org.apache.stratos.common.listeners.TenantMgtListener; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * This class is used to listen to the tenant creation events and fire the keystore creation event - */ -public class KeystoreTenantMgtListener implements TenantMgtListener { - - private static Log log = LogFactory.getLog(KeystoreTenantMgtListener.class); - private static final int EXEC_ORDER = 20; - - /** - * Generate the keystore when a new tenant is registered. - * @param tenantInfo Information about the newly created tenant - */ - public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException { - try { - KeyStoreGenerator ksGenerator = new KeyStoreGenerator(tenantInfo.getTenantId()); - if (!ksGenerator.isKeyStoreExists()){ - ksGenerator.generateKeyStore(); - } - } catch (KeyStoreMgtException e) { - String message = "Error when generating the keystore"; - log.error(message, e); - throw new ApacheStratosException(message, e); - } - } - - public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException { - // It is not required to implement this method for keystore mgt. - } - - public void onTenantDelete(int tenantId) { - // It is not required to implement this method for keystore mgt. - } - - public void onTenantRename(int tenantId, String oldDomainName, - String newDomainName) throws ApacheStratosException { - // It is not required to implement this method for keystore mgt. - } - - public int getListenerOrder() { - return EXEC_ORDER; - } - - public void onTenantInitialActivation(int tenantId) throws ApacheStratosException { - // It is not required to implement this method for keystore mgt. - } - - public void onTenantActivation(int tenantId) throws ApacheStratosException { - // It is not required to implement this method for keystore mgt. - } - - public void onTenantDeactivation(int tenantId) throws ApacheStratosException { - // It is not required to implement this method for keystore mgt. - } - - public void onSubscriptionPlanChange(int tenentId, String oldPlan, - String newPlan) throws ApacheStratosException { - // It is not required to implement this method for keystore mgt. - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/internal/KeyStoreMgtServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/internal/KeyStoreMgtServiceComponent.java b/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/internal/KeyStoreMgtServiceComponent.java deleted file mode 100644 index b2e6dc8..0000000 --- a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/internal/KeyStoreMgtServiceComponent.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.keystore.mgt.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.user.core.service.RealmService; -import org.apache.stratos.keystore.mgt.KeystoreTenantMgtListener; -import org.apache.stratos.keystore.mgt.util.RealmServiceHolder; -import org.apache.stratos.keystore.mgt.util.RegistryServiceHolder; - -/** - * @scr.component name="org.apache.stratos.keystore.mgt" - * immediate="true" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1" - * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" - * @scr.reference name="user.realmservice.default" interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" policy="dynamic" bind="setRealmService" - * unbind="unsetRealmService" - */ -public class KeyStoreMgtServiceComponent { - - private static Log log = LogFactory.getLog(KeyStoreMgtServiceComponent.class); - - - protected void activate(ComponentContext ctxt){ - KeystoreTenantMgtListener keystoreTenantMgtListener = new KeystoreTenantMgtListener(); - ctxt.getBundleContext().registerService( - org.apache.stratos.common.listeners.TenantMgtListener.class.getName(), - keystoreTenantMgtListener, null); - if (log.isDebugEnabled()) { - log.debug("*************Stratos Keystore mgt component is activated.**************"); - } - } - - protected void deactivate(ComponentContext ctxt) { - if(log.isDebugEnabled()){ - log.debug("************Stratos keystore mgt component is decativated.*************"); - } - } - - protected void setRegistryService(RegistryService registryService){ - RegistryServiceHolder.setRegistryService(registryService); - if (log.isDebugEnabled()) { - log.debug("Registry Service is set for KeyStoreMgtServiceComponent."); - } - } - - protected void unsetRegistryService(RegistryService registryService){ - RegistryServiceHolder.setRegistryService(null); - if(log.isDebugEnabled()){ - log.debug("Registry Service is unset for KeyStoreMgtServiceComponent."); - } - } - - protected void setRealmService(RealmService realmService){ - RealmServiceHolder.setRealmService(realmService); - if (log.isDebugEnabled()) { - log.debug("Realm Service is set for KeyStoreMgtServiceComponent."); - } - } - - protected void unsetRealmService(RealmService realmService){ - RealmServiceHolder.setRealmService(null); - if(log.isDebugEnabled()){ - log.debug("Realm Service is unset for KeyStoreMgtServiceComponent."); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RealmServiceHolder.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RealmServiceHolder.java b/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RealmServiceHolder.java deleted file mode 100644 index cee59f1..0000000 --- a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RealmServiceHolder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.keystore.mgt.util; - -import org.wso2.carbon.user.core.service.RealmService; - -public class RealmServiceHolder { - - private static RealmService realmServiceService; - - public static RealmService getRealmService() { - return realmServiceService; - } - - public static void setRealmService(RealmService realmService) { - RealmServiceHolder.realmServiceService = realmService; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RegistryServiceHolder.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RegistryServiceHolder.java b/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RegistryServiceHolder.java deleted file mode 100644 index e71c299..0000000 --- a/components/org.apache.stratos.keystore.mgt/src/main/java/org/apache/stratos/keystore/mgt/util/RegistryServiceHolder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.keystore.mgt.util; - -import org.wso2.carbon.registry.core.service.RegistryService; - -public class RegistryServiceHolder { - - private static RegistryService registryService; - - public static RegistryService getRegistryService() { - return registryService; - } - - public static void setRegistryService(RegistryService registryService) { - RegistryServiceHolder.registryService = registryService; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java index 1683aa6..825b068 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java @@ -225,7 +225,7 @@ public class StratosManagerServiceComponent { TenantUserRoleManager tenantUserRoleManager = new TenantUserRoleManager(); componentContext.getBundleContext().registerService( - org.apache.stratos.common.listeners.TenantMgtListener.class.getName(), + org.wso2.carbon.stratos.common.listeners.TenantMgtListener.class.getName(), tenantUserRoleManager, null); } @@ -241,7 +241,7 @@ public class StratosManagerServiceComponent { } final TenantEventPublisher tenantEventPublisher = new TenantEventPublisher(); componentContext.getBundleContext().registerService( - org.apache.stratos.common.listeners.TenantMgtListener.class.getName(), + org.wso2.carbon.stratos.common.listeners.TenantMgtListener.class.getName(), tenantEventPublisher, null); if (log.isInfoEnabled()) { log.info("Tenant event publisher initialized"); http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java index 863050f..dfdce5b 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java @@ -21,15 +21,14 @@ package org.apache.stratos.manager.messaging.publisher; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.exception.ApacheStratosException; -import org.apache.stratos.common.listeners.TenantMgtListener; +import org.wso2.carbon.stratos.common.beans.TenantInfoBean; +import org.wso2.carbon.stratos.common.exception.StratosException; +import org.wso2.carbon.stratos.common.listeners.TenantMgtListener; import org.apache.stratos.messaging.broker.publish.EventPublisher; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.domain.tenant.Tenant; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.tenant.TenantCreatedEvent; -import org.apache.stratos.messaging.event.tenant.TenantRemovedEvent; import org.apache.stratos.messaging.event.tenant.TenantUpdatedEvent; import org.apache.stratos.messaging.util.MessagingUtil; @@ -49,7 +48,7 @@ public class TenantEventPublisher implements TenantMgtListener { } @Override - public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException { + public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException { try { if (log.isDebugEnabled()) { log.debug(String.format("Publishing tenant created event: [tenant-id] %d [tenant-domain] %s", @@ -66,7 +65,7 @@ public class TenantEventPublisher implements TenantMgtListener { } @Override - public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException { + public void onTenantUpdate(TenantInfoBean tenantInfo) throws StratosException { try { if (log.isInfoEnabled()) { log.info(String.format("Publishing tenant updated event: [tenant-id] %d [tenant-domain] %s", @@ -83,36 +82,23 @@ public class TenantEventPublisher implements TenantMgtListener { } @Override - public void onTenantDelete(int tenantId) { - try { - if (log.isInfoEnabled()) { - log.info(String.format("Publishing tenant removed event: [tenant-id] %d", tenantId)); - } - TenantRemovedEvent event = new TenantRemovedEvent(tenantId); - publish(event); - } catch (Exception e) { - log.error(String.format("Could not publish tenant removed event [tenant-id] %d", tenantId), e); - } - } - - @Override - public void onTenantRename(int tenantId, String oldDomainName, String newDomainName) throws ApacheStratosException { + public void onTenantRename(int tenantId, String oldDomainName, String newDomainName) throws StratosException { } @Override - public void onTenantInitialActivation(int tenantId) throws ApacheStratosException { + public void onTenantInitialActivation(int tenantId) throws StratosException { } @Override - public void onTenantActivation(int tenantId) throws ApacheStratosException { + public void onTenantActivation(int tenantId) throws StratosException { } @Override - public void onTenantDeactivation(int tenantId) throws ApacheStratosException { + public void onTenantDeactivation(int tenantId) throws StratosException { } @Override - public void onSubscriptionPlanChange(int tenantId, String oldPlan, String newPlan) throws ApacheStratosException { + public void onSubscriptionPlanChange(int tenantId, String oldPlan, String newPlan) throws StratosException { } @Override http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java index ed5a029..6e721ed 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java @@ -21,9 +21,9 @@ package org.apache.stratos.manager.user.management; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.exception.ApacheStratosException; -import org.apache.stratos.common.listeners.TenantMgtListener; +import org.wso2.carbon.stratos.common.beans.TenantInfoBean; +import org.wso2.carbon.stratos.common.exception.StratosException; +import org.wso2.carbon.stratos.common.listeners.TenantMgtListener; import org.apache.stratos.manager.internal.ServiceReferenceHolder; import org.apache.stratos.manager.user.management.exception.UserManagerException; import org.apache.stratos.manager.utils.UserRoleCreator; @@ -43,10 +43,10 @@ public class TenantUserRoleManager implements TenantMgtListener { * Create an 'user' role at tenant creation time * * @param tenantInfo TenantInfoBean - * @throws org.apache.stratos.common.exception.ApacheStratosException + * @throws org.wso2.carbon.stratos.common.exception.StratosException */ @Override - public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException { + public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException { try { @@ -64,11 +64,11 @@ public class TenantUserRoleManager implements TenantMgtListener { } catch (UserStoreException e) { String msg = "Error while retrieving the user store for tenant: " + tenantInfo.getTenantDomain(); log.error(msg, e); - throw new ApacheStratosException(e.getMessage(), e); + throw new StratosException(e.getMessage(), e); } catch (UserManagerException e) { String msg = "Error while creating the user role in tenant: " + tenantInfo.getTenantDomain(); log.error(msg, e); - throw new ApacheStratosException(e.getMessage(), e); + throw new StratosException(e.getMessage(), e); } finally { PrivilegedCarbonContext.endTenantFlow(); } @@ -77,39 +77,34 @@ public class TenantUserRoleManager implements TenantMgtListener { @Override - public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException { - - } - - @Override - public void onTenantDelete(int tenantId) { + public void onTenantUpdate(TenantInfoBean tenantInfo) throws StratosException { } @Override public void onTenantRename(int tenantId, String oldDomainName, String newDomainName) - throws ApacheStratosException { + throws StratosException { } @Override - public void onTenantInitialActivation(int tenantId) throws ApacheStratosException { + public void onTenantInitialActivation(int tenantId) throws StratosException { } @Override - public void onTenantActivation(int tenantId) throws ApacheStratosException { + public void onTenantActivation(int tenantId) throws StratosException { } @Override - public void onTenantDeactivation(int tenantId) throws ApacheStratosException { + public void onTenantDeactivation(int tenantId) throws StratosException { } @Override public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan) - throws ApacheStratosException { + throws StratosException { } http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 3ce9554..a32a5c3 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3053,15 +3053,6 @@ public class StratosApiV41Utils { throw new RestAPIException(msg); } - try { - TenantUserRoleManager tenantUserRoleManager = new TenantUserRoleManager(); - tenantUserRoleManager.onTenantCreate(tenantInfoBean); - } catch (ApacheStratosException e) { - String message = "Could create Internal/user role for tenant"; - log.error(message, e); - throw new RestAPIException(message); - } - // For the super tenant tenant creation, tenants are always activated as they are created. try { TenantMgtUtil.activateTenantInitially( http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/components/pom.xml ---------------------------------------------------------------------- diff --git a/components/pom.xml b/components/pom.xml index abf4ff6..94badb4 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -64,7 +64,6 @@ <!-- Domain Validation --> <!-- Redirector --> <module>org.apache.stratos.sso.redirector.ui</module> - <module>org.apache.stratos.keystore.mgt</module> <!--Logging mgt--> <module>org.apache.stratos.logging.view.ui</module> <!-- RESTful admin services --> http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/features/common/org.apache.stratos.common.server.feature/pom.xml ---------------------------------------------------------------------- diff --git a/features/common/org.apache.stratos.common.server.feature/pom.xml b/features/common/org.apache.stratos.common.server.feature/pom.xml index a637ba7..81f9663 100644 --- a/features/common/org.apache.stratos.common.server.feature/pom.xml +++ b/features/common/org.apache.stratos.common.server.feature/pom.xml @@ -115,11 +115,6 @@ <version>${kaptcha.patch.version.230-wso2v1}</version> </dependency> <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.keystore.mgt</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>org.wso2.carbon</groupId> <artifactId>org.wso2.carbon.captcha.mgt</artifactId> <version>${wso2carbon.version}</version> @@ -205,7 +200,6 @@ <!-- Tenant Mgmt --> <bundleDef>org.json.wso2:json</bundleDef> <bundleDef>kaptcha.wso2:kaptcha</bundleDef> - <bundleDef>org.apache.stratos:org.apache.stratos.keystore.mgt</bundleDef> <bundleDef>org.wso2.carbon:org.wso2.carbon.captcha.mgt</bundleDef> <bundleDef>org.wso2.carbon:org.wso2.carbon.theme.mgt:2.2.0</bundleDef> <!-- End Tenant Mgmt --> http://git-wip-us.apache.org/repos/asf/stratos/blob/ad2e7d53/products/stratos/modules/distribution/src/main/license/LICENSE ---------------------------------------------------------------------- diff --git a/products/stratos/modules/distribution/src/main/license/LICENSE b/products/stratos/modules/distribution/src/main/license/LICENSE index 79a5fa6..f62819a 100644 --- a/products/stratos/modules/distribution/src/main/license/LICENSE +++ b/products/stratos/modules/distribution/src/main/license/LICENSE @@ -363,7 +363,6 @@ org.apache.stratos.cloud.controller.service.stub_4.1.0.jar, org.apache.stratos.cloud.controller_4.1.0.jar, org.apache.stratos.common_4.1.0.jar, org.apache.stratos.custom.handlers_4.1.0.jar, -org.apache.stratos.keystore.mgt_4.1.0.jar, org.apache.stratos.kubernetes.client_4.1.0.jar, org.apache.stratos.logging.view.ui_4.1.0.jar, org.apache.stratos.manager.service.stub_4.1.0.jar,
