diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt.ui/pom.xml b/components/application-mgt/org.wso2.carbon.identity.application.mgt.ui/pom.xml index ac6bb6c58c9..5cab716c9ba 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt.ui/pom.xml +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt.ui/pom.xml @@ -87,7 +87,7 @@ org.wso2.carbon.identity.application.common - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/pom.xml b/components/application-mgt/org.wso2.carbon.identity.application.mgt/pom.xml index f302926c5a4..698df7b612f 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/pom.xml +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/pom.xml @@ -90,7 +90,7 @@ org.wso2.carbon.consent.mgt.core - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt.ui/pom.xml b/components/idp-mgt/org.wso2.carbon.idp.mgt.ui/pom.xml index 734b341a0eb..48f989b60a8 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt.ui/pom.xml +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt.ui/pom.xml @@ -80,7 +80,7 @@ org.wso2.carbon.identity.application.default.auth.sequence.mgt.stub - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/pom.xml b/components/security-mgt/org.wso2.carbon.security.mgt.ui/pom.xml deleted file mode 100644 index 7b610379511..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - security-mgt - 5.25.293-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.security.mgt.ui - bundle - WSO2 Carbon - Security UI - This is the core module of the project. - - - - org.wso2.carbon - org.wso2.carbon.ui - - - org.apache.axis2.wso2 - axis2 - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon.identity.framework - org.wso2.carbon.security.mgt.stub - - - org.wso2.carbon.identity.framework - org.wso2.carbon.user.mgt.common - - - org.wso2.carbon.identity.framework - org.wso2.carbon.user.mgt.ui - - - org.wso2.orbit.org.owasp.encoder - encoder - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.core - - - - - - - org.apache.felix - maven-bundle-plugin - - true - - - ${project.artifactId} - ${project.artifactId} - - javax.activation; version="[0.0.0,0.1.0)", - org.apache.axis2.*; version="${axis2.osgi.version.range}", - org.apache.axiom.om.util; version="${axiom.osgi.version.range}", - org.apache.commons.fileupload.*; version="${commons-fileupload.imp.pkg.version.range}", - org.apache.commons.logging; version="${import.package.version.commons.logging}", - org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}", - org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}", - org.osgi.util.tracker; version="${osgi.util.tracker.imp.pkg.version.range}", - org.wso2.carbon.registry.core.*; version="${carbon.kernel.registry.imp.pkg.version}", - org.wso2.carbon.security.mgt.stub.*; - version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.sts.common.stub.config.*; - version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.user.mgt.stub.types.carbon; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.core.*; - version="${carbon.identity.package.import.version.range}" - - - org.wso2.carbon.security.ui.*; version="${carbon.identity.package.export.version}" - - UIBundle - - - - - org.codehaus.mojo - findbugs-maven-plugin - - High - - - - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/SecurityUIConstants.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/SecurityUIConstants.java deleted file mode 100644 index cfcb8b5a9ff..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/SecurityUIConstants.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.ui; - -/** - * Class containing the constants used by Security Mgt UI component. - */ -public class SecurityUIConstants { - - public static final int DEFAULT_ITEMS_PER_PAGE = 10; - public static final int CACHING_PAGE_SIZE = 5; - public static final String PAGINATED_KEY_STORE_DATA = "PaginatedKeyStoreData"; - public static final String STARTING_CERT_DATA_PAGE = "starting_page"; - - public static final String USER_ADMIN_CLIENT = "UserAdminClient"; - public static final String FLAGGED_NAME_PAGE_COUNT = "FlaggedNamePageCount"; - - public static final String ROLE_LIST_FILTER = "org.wso2.carbon.role.filter"; - public static final String USER_STORE_INFO = "org.wso2.carbon.userstore.info"; - public static final String ALL_DOMAINS = "ALL-USER-STORE-DOMAINS"; - public static final String DOMAIN_SEPARATOR = "/"; - public static final String ROLE_LIST_DOMAIN_FILTER = "org.wso2.carbon.role.domain.filter"; - - public static final int KEYSTORE_DEFAULT_ITEMS_PER_PAGE = 5; - public static final String SESSION_ATTR_KEYSTORES = "keystores"; - public static final String RE_FETCH_KEYSTORES = "refetchKeystores"; - - public static final String KEYSTORE_LIST_FILTER = "org.wso2.carbon.keystore.filter"; - public static final String KEYSTORE_CERT_LIST_FILTER = "org.wso2.carbon.keystore.cert.filter"; - - private SecurityUIConstants() { - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/ServiceHolder.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/ServiceHolder.java deleted file mode 100644 index 100045ec9c2..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/ServiceHolder.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.ui; - -import org.osgi.framework.BundleContext; -import org.osgi.util.tracker.ServiceTracker; -import org.wso2.carbon.registry.core.service.RegistryService; - -/** - * Singleton ServiceHolder used for registry service operations. - */ -public class ServiceHolder { - - private static ServiceHolder instance = null; - - private static BundleContext bundleContext; - - private static ServiceTracker registryTracker = null; - - private ServiceHolder() { - - } - - public static void init(BundleContext context) { - - bundleContext = context; - registryTracker = new ServiceTracker(bundleContext, RegistryService.class.getName(), null); - registryTracker.open(); - instance = new ServiceHolder(); - - } - - public static ServiceHolder getInstance() { - - return instance; - } - - public RegistryService getRegistryService() { - - return (RegistryService) registryTracker.getService(); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/Util.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/Util.java deleted file mode 100644 index ba6a30f74d3..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/Util.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.ui; - -import org.wso2.carbon.security.mgt.stub.keystore.xsd.CertData; -import org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData; -import org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName; - -import java.util.ArrayList; -import java.util.List; - -/** - * JSP Utility class for Security Mgt UI component. - */ -public class Util { - - private Util(){} - - public static CertData[] doPaging(int pageNumber, CertData[] certDataSet) { - - int itemsPerPageInt = SecurityUIConstants.DEFAULT_ITEMS_PER_PAGE; - int startIndex = pageNumber * itemsPerPageInt; - int endIndex = (pageNumber + 1) * itemsPerPageInt; - CertData[] returnedCertDataSet = new CertData[itemsPerPageInt]; - - for (int i = startIndex, j = 0; i < endIndex && i < certDataSet.length; i++, j++) { - returnedCertDataSet[j] = certDataSet[i]; - } - - return returnedCertDataSet; - } - - public static KeyStoreData[] doPaging(int pageNumber, KeyStoreData[] keyStoreDataSet) { - - int itemsPerPageInt = SecurityUIConstants.KEYSTORE_DEFAULT_ITEMS_PER_PAGE; - int startIndex = pageNumber * itemsPerPageInt; - int endIndex = (pageNumber + 1) * itemsPerPageInt; - KeyStoreData[] returnedDataSet = new KeyStoreData[itemsPerPageInt]; - - for (int i = startIndex, j = 0; i < endIndex && i < keyStoreDataSet.length; i++, j++) { - returnedDataSet[j] = keyStoreDataSet[i]; - } - - return returnedDataSet; - } - - public static FlaggedName[] doFlaggedNamePaging(int pageNumber, FlaggedName[] flaggedName) { - - int itemsPerPageInt = SecurityUIConstants.DEFAULT_ITEMS_PER_PAGE; - FlaggedName[] returnedFlaggedNameSet; - - int startIndex = pageNumber * itemsPerPageInt; - int endIndex = (pageNumber + 1) * itemsPerPageInt; - if (itemsPerPageInt < flaggedName.length - 1) { - returnedFlaggedNameSet = new FlaggedName[itemsPerPageInt]; - } else { - returnedFlaggedNameSet = new FlaggedName[flaggedName.length - 1]; - } - for (int i = startIndex, j = 0; i < endIndex && i < flaggedName.length - 1; i++, j++) { - returnedFlaggedNameSet[j] = flaggedName[i]; - } - - return returnedFlaggedNameSet; - } - - public static KeyStoreData[] doFilter(String filter, KeyStoreData[] keyStoreDataSet) { - - String regPattern = filter.replace("*", ".*"); - List list = new ArrayList<>(); - - for (KeyStoreData keyStore : keyStoreDataSet) { - if (keyStore != null && keyStore.getKeyStoreName().toLowerCase().matches(regPattern.toLowerCase())) { - list.add(keyStore); - } - } - - return list.toArray(new KeyStoreData[list.size()]); - } - - public static CertData[] doFilter(String filter, CertData[] certDataSet) { - - if (certDataSet == null || certDataSet.length == 0) { - return new CertData[0]; - } - - String regPattern = filter.replace("*", ".*"); - List list = new ArrayList<>(); - - for (CertData cert : certDataSet) { - if (cert != null - && cert.getAlias().toLowerCase() - .matches(regPattern.toLowerCase())) { - list.add(cert); - } - } - - return list.toArray(new CertData[list.size()]); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/KeyStoreAdminClient.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/KeyStoreAdminClient.java deleted file mode 100644 index a4cdcc66448..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/KeyStoreAdminClient.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.ui.client; - -import org.apache.axiom.om.util.Base64; -import org.apache.axis2.AxisFault; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.identity.core.util.IdentityIOStreamUtils; -import org.wso2.carbon.security.mgt.stub.keystore.AddKeyStore; -import org.wso2.carbon.security.mgt.stub.keystore.AddTrustStore; -import org.wso2.carbon.security.mgt.stub.keystore.DeleteStore; -import org.wso2.carbon.security.mgt.stub.keystore.GetFilteredPaginatedKeyStoreInfo; -import org.wso2.carbon.security.mgt.stub.keystore.GetFilteredPaginatedKeyStoreInfoResponse; -import org.wso2.carbon.security.mgt.stub.keystore.GetKeyStoresResponse; -import org.wso2.carbon.security.mgt.stub.keystore.GetKeystoreInfo; -import org.wso2.carbon.security.mgt.stub.keystore.GetKeystoreInfoResponse; -import org.wso2.carbon.security.mgt.stub.keystore.GetPaginatedKeystoreInfo; -import org.wso2.carbon.security.mgt.stub.keystore.GetPaginatedKeystoreInfoResponse; -import org.wso2.carbon.security.mgt.stub.keystore.GetStoreEntries; -import org.wso2.carbon.security.mgt.stub.keystore.GetStoreEntriesResponse; -import org.wso2.carbon.security.mgt.stub.keystore.ImportCertToStore; -import org.wso2.carbon.security.mgt.stub.keystore.KeyStoreAdminServiceStub; -import org.wso2.carbon.security.mgt.stub.keystore.RemoveCertFromStore; -import org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData; -import org.wso2.carbon.security.mgt.stub.keystore.xsd.PaginatedKeyStoreData; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.KeyStore; -import java.util.Enumeration; - -/** - * Client class for KeyStoreAdminServiceStub. - */ -public class KeyStoreAdminClient { - - private static final Log log = LogFactory.getLog(KeyStoreAdminClient.class); - private String serviceEndPoint = null; - private KeyStoreAdminServiceStub stub = null; - - public KeyStoreAdminClient(String cookie, String url, ConfigurationContext configContext) - throws java.lang.Exception { - - try { - this.serviceEndPoint = url + "KeyStoreAdminService"; - this.stub = new KeyStoreAdminServiceStub(configContext, serviceEndPoint); - ServiceClient client = stub._getServiceClient(); - Options option = client.getOptions(); - option.setManageSession(true); - option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); - } catch (AxisFault e) { - log.error("Error in creating KeyStoreAdminClient", e); - throw e; - } - - } - - public KeyStoreData[] getKeyStores() throws java.lang.Exception { - - try { - GetKeyStoresResponse response = stub.getKeyStores(); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting keystore data", e); - throw e; - } - } - - public void addKeyStore(byte[] content, String filename, String password, String provider, - String type, String pvtkspass) throws java.lang.Exception { - - try { - String data = Base64.encode(content); - AddKeyStore request = new AddKeyStore(); - request.setFileData(data); - request.setFilename(filename); - request.setPassword(password); - request.setProvider(provider); - request.setType(type); - request.setPvtkeyPass(pvtkspass); - stub.addKeyStore(request); - } catch (java.lang.Exception e) { - log.error("Error in adding keystore", e); - throw e; - } - } - - public void addTrustStore(byte[] content, String filename, String password, String provider, - String type) { - - try { - String data = Base64.encode(content); - AddTrustStore request = new AddTrustStore(); - - request.setFileData(data); - request.setFilename(filename); - request.setPassword(password); - request.setProvider(provider); - request.setType(type); - stub.addTrustStore(request); - } catch (java.lang.Exception e) { - log.error("Error in adding truststore", e); - } - } - - public void deleteStore(String keyStoreName) throws java.lang.Exception { - - try { - DeleteStore request = new DeleteStore(); - request.setKeyStoreName(keyStoreName); - stub.deleteStore(request); - } catch (java.lang.Exception e) { - log.error("Error in deleting keystore", e); - throw e; - } - } - - public void importCertToStore(String filename, byte[] content, String keyStoreName) - throws java.lang.Exception { - - try { - String data = Base64.encode(content); - ImportCertToStore request = new ImportCertToStore(); - request.setFileName(filename); - request.setFileData(data); - request.setKeyStoreName(keyStoreName); - stub.importCertToStore(request); - } catch (java.lang.Exception e) { - log.error("Error in importing cert to store.", e); - throw e; - } - } - - public String[] getStoreEntries(String keyStoreName) throws java.lang.Exception { - - try { - GetStoreEntries request = new GetStoreEntries(); - request.setKeyStoreName(keyStoreName); - GetStoreEntriesResponse response = stub.getStoreEntries(request); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting store entries.", e); - throw e; - } - } - - private byte[] getBytesFromFile(File file) throws java.lang.Exception { - - InputStream is = new FileInputStream(file); - try { - // Get the size of the file - long length = file.length(); - - if (length > Integer.MAX_VALUE) { - throw new IOException("File is too large"); - } - - // Create the byte array to hold the data - byte[] bytes = new byte[(int) length]; - - // Read in the bytes - int offset = 0; - int numRead = 0; - while (offset < bytes.length - && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { - offset += numRead; - } - - if (offset < bytes.length) { - throw new IOException("Could not completely read file " + file.getName()); - } - return bytes; - } catch (java.lang.Exception e) { - log.error("Error in getting bytes from file.", e); - throw e; - } finally { - IdentityIOStreamUtils.closeInputStream(is); - } - } - - public boolean isPrivateKeyStore(byte[] content, String password, String type) - throws java.lang.Exception { - - try { - boolean isPrivateStore = false; - ByteArrayInputStream stream = new ByteArrayInputStream(content); - KeyStore store = KeyStore.getInstance(type); - store.load(stream, password.toCharArray()); - Enumeration aliases = store.aliases(); - while (aliases.hasMoreElements()) { - String value = aliases.nextElement(); - if (store.isKeyEntry(value)) { - isPrivateStore = true; - break; - } - } - return isPrivateStore; - } catch (java.lang.Exception e) { - log.error("Error in checking private key store.", e); - throw e; - } - } - - public KeyStoreData getKeystoreInfo(String keyStoreName) throws java.lang.Exception { - - try { - GetKeystoreInfo request = new GetKeystoreInfo(); - request.setKeyStoreName(keyStoreName); - GetKeystoreInfoResponse response = stub.getKeystoreInfo(request); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting keystore info.", e); - throw e; - } - } - - public void removeCertificateFromKeyStore(String keySoreName, String certificateAlias) throws java.lang.Exception { - - RemoveCertFromStore request = new RemoveCertFromStore(); - request.setKeyStoreName(keySoreName); - request.setAlias(certificateAlias); - try { - stub.removeCertFromStore(request); - } catch (java.lang.Exception e) { - log.error("Error in removing certificate from keystore.", e); - throw e; - } - } - - public PaginatedKeyStoreData getPaginatedKeystoreInfo(String keyStoreName, int pageNumber) - throws java.lang.Exception { - - try { - GetPaginatedKeystoreInfo request = new GetPaginatedKeystoreInfo(); - request.setKeyStoreName(keyStoreName); - request.setPageNumber(pageNumber); - - GetPaginatedKeystoreInfoResponse response = stub.getPaginatedKeystoreInfo(request); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting paginated keystore info.", e); - throw e; - } - } - - /** - * Get keystore info with paginated and filtered certificates by given filter. - * - * @param keyStoreName Keystore name. - * @param pageNumber Page number. - * @param filter Filter text. - * @return Paginated keystore data with certificates. - * @throws java.lang.Exception - */ - public PaginatedKeyStoreData getFilteredPaginatedKeyStoreInfo(String keyStoreName, int pageNumber, - String filter) throws java.lang.Exception { - - try { - GetFilteredPaginatedKeyStoreInfo request = new GetFilteredPaginatedKeyStoreInfo(); - request.setKeyStoreName(keyStoreName); - request.setPageNumber(pageNumber); - request.setFilter(filter); - - GetFilteredPaginatedKeyStoreInfoResponse response = stub.getFilteredPaginatedKeyStoreInfo(request); - return response.get_return(); - } catch (java.lang.Exception e) { - throw e; - } - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/KeyStoreBean.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/KeyStoreBean.java deleted file mode 100644 index 6e78f48582a..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/KeyStoreBean.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.ui.client; - -/** - * Blue print for KeyStoreBean Object. - */ -public class KeyStoreBean { - - private String ksPassword = ""; - private String provider = ""; - private String keystoreType = ""; - - public String getKsPassword() { - - return ksPassword; - } - - public void setKsPassword(String ksPassword) { - - this.ksPassword = ksPassword; - } - - public String getProvider() { - - return provider; - } - - public void setProvider(String provider) { - - this.provider = provider; - } - - public String getKeystoreType() { - - return keystoreType; - } - - public void setKeystoreType(String keystoreType) { - - this.keystoreType = keystoreType; - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/SecurityAdminClient.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/SecurityAdminClient.java deleted file mode 100644 index 989058e0ca5..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/client/SecurityAdminClient.java +++ /dev/null @@ -1,168 +0,0 @@ -/* -* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. 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.wso2.carbon.security.ui.client; - -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityConfigData; -import org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityScenarioData; -import org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityScenarioDataWrapper; -import org.wso2.carbon.security.mgt.stub.config.ActivateUsernameTokenAuthentication; -import org.wso2.carbon.security.mgt.stub.config.ApplyKerberosSecurityPolicy; -import org.wso2.carbon.security.mgt.stub.config.ApplySecurity; -import org.wso2.carbon.security.mgt.stub.config.DisableSecurityOnService; -import org.wso2.carbon.security.mgt.stub.config.GetScenarios; -import org.wso2.carbon.security.mgt.stub.config.GetScenariosResponse; -import org.wso2.carbon.security.mgt.stub.config.GetSecurityConfigData; -import org.wso2.carbon.security.mgt.stub.config.GetSecurityConfigDataResponse; -import org.wso2.carbon.security.mgt.stub.config.GetSecurityScenario; -import org.wso2.carbon.security.mgt.stub.config.GetSecurityScenarioResponse; -import org.wso2.carbon.security.mgt.stub.config.SecurityAdminServiceStub; - -/** - * Client class for SecurityAdminServiceStub. - */ -public class SecurityAdminClient { - - private static final Log log = LogFactory.getLog(SecurityAdminClient.class); - private SecurityAdminServiceStub stub = null; - - public SecurityAdminClient(String cookie, String url, ConfigurationContext configContext) - throws java.lang.Exception { - - try { - String serviceEndPoint = url + "SecurityAdminService"; - this.stub = new SecurityAdminServiceStub(configContext, serviceEndPoint); - - ServiceClient client = stub._getServiceClient(); - Options option = client.getOptions(); - option.setManageSession(true); - option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); - } catch (java.lang.Exception e) { - log.error("Error in creating SecurityAdminClient", e); - throw e; - } - } - - public void activateUsernameTokenAuthentication(String serviceName, String[] userGroups) - throws java.lang.Exception { - - try { - ActivateUsernameTokenAuthentication request = new ActivateUsernameTokenAuthentication(); - request.setServiceName(serviceName); - request.setUserGroups(userGroups); - stub.activateUsernameTokenAuthentication(request); - } catch (java.lang.Exception e) { - log.error("Error in activating username token authentication.", e); - throw e; - } - } - - public void disableSecurityOnService(String serviceName) throws java.lang.Exception { - - try { - DisableSecurityOnService request = new DisableSecurityOnService(); - request.setServiceName(serviceName); - stub.disableSecurityOnService(request); - } catch (java.lang.Exception e) { - log.error("Error in disabling security on service", e); - throw e; - } - } - - public void applyKerberosSecurity(String serviceName, String scenarioId, String servicePrincipal, - String password) throws java.lang.Exception { - - try { - ApplyKerberosSecurityPolicy request = new ApplyKerberosSecurityPolicy(); - request.setServiceName(serviceName); - request.setPolicyId(scenarioId); - request.setServicePrincipalName(servicePrincipal); - request.setServicePrincipalPassword(password); - - stub.applyKerberosSecurityPolicy(request); - } catch (java.lang.Exception e) { - log.error("Error in applying kerberos security.", e); - throw e; - } - } - - - public void applySecurity(String serviceName, String scenarioId, String policyPath, String[] trustedStores, - String privateStore, String[] userGroups) throws java.lang.Exception { - - try { - ApplySecurity request = new ApplySecurity(); - request.setServiceName(serviceName); - request.setPolicyId(scenarioId); - request.setPolicyPath(policyPath); - request.setTrustedStores(trustedStores); - request.setPrivateStore(privateStore); - request.setUserGroupNames(userGroups); - stub.applySecurity(request); - } catch (java.lang.Exception e) { - log.error("Error in applying security.", e); - throw e; - } - } - - public SecurityScenarioDataWrapper getScenarios(String serviceName) throws java.lang.Exception { - - try { - GetScenarios request = new GetScenarios(); - request.setServiceName(serviceName); - GetScenariosResponse response = stub.getScenarios(request); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting scenarios", e); - throw e; - } - } - - public SecurityScenarioData getSecurityScenario(String serviceId) throws java.lang.Exception { - - try { - GetSecurityScenario request = new GetSecurityScenario(); - request.setSceneId(serviceId); - GetSecurityScenarioResponse response = stub.getSecurityScenario(request); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting security scenarios", e); - throw e; - } - } - - public SecurityConfigData getSecurityConfigData(String serviceName, String scenrioId, String policyPath) - throws java.lang.Exception { - - try { - GetSecurityConfigData request = new GetSecurityConfigData(); - request.setServiceName(serviceName); - request.setScenarioId(scenrioId); - request.setPolicyPath(policyPath); - GetSecurityConfigDataResponse response = stub.getSecurityConfigData(request); - return response.get_return(); - } catch (java.lang.Exception e) { - log.error("Error in getting security config data", e); - throw e; - } - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/jsp/SecurityUIUtil.java b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/jsp/SecurityUIUtil.java deleted file mode 100644 index bbd9724c350..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/java/org/wso2/carbon/security/ui/jsp/SecurityUIUtil.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.ui.jsp; - -import org.apache.axis2.builder.DiskFileDataSource; -import org.apache.commons.fileupload.FileItemFactory; -import org.apache.commons.fileupload.FileUploadException; -import org.apache.commons.fileupload.disk.DiskFileItem; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.apache.commons.fileupload.servlet.ServletRequestContext; -import org.apache.commons.lang.StringUtils; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.security.ui.ServiceHolder; - -import java.nio.charset.StandardCharsets; -import java.util.List; - -import javax.activation.DataHandler; -import javax.activation.DataSource; - -/** - * JSP Utility class for Security Mgt UI component. - */ -public class SecurityUIUtil { - - private static String url = null; - - private SecurityUIUtil() { - } - - public static String getUrl() throws Exception { - - if (url == null) { - ServiceHolder serviceHodler = ServiceHolder.getInstance(); - RegistryService regService = serviceHodler.getRegistryService(); - Registry systemRegistry = regService.getConfigSystemRegistry(); - Resource resource = systemRegistry.get("/carbon/connection/props"); - String servicePath = resource.getProperty("service-path"); - String contextRoot = resource.getProperty("context-root"); - - String host = resource.getProperty("host-name"); - contextRoot = StringUtils.equals("/", contextRoot) ? "" : contextRoot; - - host = (host == null) ? "localhost" : host; - String port = System.getProperty("carbon.https.port"); - StringBuilder urlValue = new StringBuilder(); - url = (urlValue.append("https://").append(host).append(":").append(port).append("/") - .append(contextRoot).append(servicePath).append("/")).toString(); - } - - return url; - } - - public static List parseRequest(ServletRequestContext requestContext) - throws FileUploadException { - - FileItemFactory factory = new DiskFileItemFactory(); - ServletFileUpload upload = new ServletFileUpload(factory); - return upload.parseRequest(requestContext); - } - - public static String getTextParameter(DiskFileItem diskFileItem, String characterEncoding) - throws Exception { - - String encoding = diskFileItem.getCharSet(); - if (encoding == null) { - encoding = characterEncoding; - } - String textValue; - if (encoding == null) { - textValue = new String(diskFileItem.get(), StandardCharsets.UTF_8); - } else { - textValue = new String(diskFileItem.get(), encoding); - } - return textValue; - } - - public static DataHandler getFileParameter(DiskFileItem diskFileItem) throws Exception { - - DataSource dataSource = new DiskFileDataSource(diskFileItem); - return new DataHandler(dataSource); - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/KeyStoreAdmin.wsdl b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/KeyStoreAdmin.wsdl deleted file mode 100644 index 1b6a2e4d2d1..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/KeyStoreAdmin.wsdl +++ /dev/null @@ -1,591 +0,0 @@ - - - KeyStoreAdminService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/META-INF/component.xml b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/META-INF/component.xml deleted file mode 100644 index 5952e7c355b..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/META-INF/component.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - keystores_menu - security.keystores - org.wso2.carbon.security.ui.i18n.Resources - manage_menu - # - region1 - 3 - manage - ../keystoremgt/images/keystore.gif - /permission/admin/manage/identity/keystoremgt - - - - keystores_add_menu - security.add.keystores - org.wso2.carbon.security.ui.i18n.Resources - keystores_menu - ../keystoremgt/add-keystore-step1.jsp - region1 - 1 - manage - ../keystoremgt/images/add.gif - /permission/admin/manage/identity/keystoremgt - - - - keystores_list_menu - security.list.keystores - org.wso2.carbon.security.ui.i18n.Resources - keystores_menu - ../keystoremgt/keystore-mgt.jsp - region1 - 2 - manage - ../keystoremgt/images/list.gif - /permission/admin/manage/identity/keystoremgt - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/SecurityConfigAdmin.wsdl b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/SecurityConfigAdmin.wsdl deleted file mode 100644 index 3238f0f0de2..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/SecurityConfigAdmin.wsdl +++ /dev/null @@ -1,535 +0,0 @@ - - - SecurityAdminService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/org/wso2/carbon/security/ui/i18n/Resources.properties b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/org/wso2/carbon/security/ui/i18n/Resources.properties deleted file mode 100644 index 0f05fe63dea..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/org/wso2/carbon/security/ui/i18n/Resources.properties +++ /dev/null @@ -1,107 +0,0 @@ -security.disable=Security disabled successfully. -security.cannot.disable=Could not disable security. {0} -security.add=Security applied successfully. -security.cannot.add=Could not apply security. {0} -cert.import=Certificate imported successfully. -cert.cannot.import=Could not import certificate. {0} -cert.delete=Certificate deleted successfully. -cert.cannot.delete=Could not delete the certificate. {0} -keystore.add=Keystore added successfully. -truststore.add=Truststore added successfully. -keystore.cannot.add=Could not add the Keystore. {0} -keystore.delete=Keystore deleted successfully. -keystore.cannot.delete=Could not delete the Keystore. {0} -view.keystore=View Keystore -security.keystores=Keystores -please.select.at.leaset.one.user.group=Please select at least one user group -please.select.at.least.one.trust.store=Please select at least one trust store -activate.security=Activate Security -user.groups=User Groups -private.key.store=Private Keystore -ok=OK -please.select.a.security.scenario=Please select a default security scenario or check the Registry Policy option and provide a Registry path to a valid security policy -please.set.registry.path=You have checked the Registry policy option. But the Registry path is empty. Please set the Registry path. -disable.security.confirm=This will disable security from the service. Click Yes to confirm -security.for.the.service=Security for the service -cannot.proceed.please.select.a.service.to.enable.security=Cannot proceed. Please select a service to enable security -enable.security=Enable Security -security.scenarios=Security Scenarios -basic.scenarios=Basic Scenarios -advanced.scenarios=Advanced Scenarios -next=Next -back=Back -import=Import -delete=Delete -available.certificates=Available Certificates -alias=Alias -issuerdn=IssuerDN -notafter=NotAfter -notbefore=NotBefore -serialnumber=SerialNumber -subjectdn=SubjectDN -version=Version -certificate.of.the.private.key=Certificate of the Private Key -do.you.want.to.delete.the.keystore=Do you want to delete the Keystore -do.you.want.to.delete.the.certificate=Do you want to delete the certificate -keystore.management=Keystores -name=Name -type=Type -actions=Actions -import.cert=Import Cert -view=View -download.pub.key=Public Key -add.new.keystore=Add New Keystore -import.certificate=Import Certificate -certificate=Certificate -enter.private.key.password=Enter a private key password -step.2.specify.private.key.password=Step 2: Specify Private Key Password -private.key.password=Private Key Password -enter.private.key.password1=Private Key Password -finish=Finish -cancel=Cancel -enter.a.keystore.file=Please enter a Keystore File -enter.keystore.password=Please enter Keystore Password -step.1.upload.keystore.file=Step 1: Upload Keystore File -key.store.file=Keystore File -keystore.file=Keystore File -keystore.istruststore=Keystore type -keystore.password=Keystore Password -provider=Provider -keystore.type=Keystore Type -import.certificates.to=Import Certificates To -service.not.secured=The service \"{0}\" is not secured. -service.secured.using=The service \"{0}\" is secured using \"{1}\" -service.secured.using.policy.from.registry=The service \"{0}\" is secured using a custom policy from Registry -service.secured.using.custom.policy.select.users.and.key.stores=The service \"{0}\" is secured using a custom policy from Registry. Select user groups and Keystores according to your policy -service.secured.using.a.default.scenario=The service \"{0}\" is secured using a default scenario -next=Next -back=Back -prev=Prev -yes=Yes -no=No -trusted.key.stores=Trusted Keystores -keystore.doesnt.contain.private.key=The Keystore does not contain a private key. Please upload a Keystore that contains a private key -truststore.cannot.have.private.keys=The Truststore contains a private key. Please select Keystore to upload keystores with private keys. -sec.policy.from.registry=Policy From Registry -sec.policy.path=Policy Path -conf.registry=Configuration Registry -gov.registry=Governance Registry -scenario=Scenario -configure.kerberos.parameters=Configure Kerberos parameters -kerberos.kdc.address=KDC Address -kerberos.realm.name=Realm Name -kerberos.service.principal.name=Service Principal Name -kerberos.service.principal.password=Service Principal Password -kerberos.des.aes.factor=DES-AES Factor -kerberos.use.subject.credentials.only=Use Subject Credentials Only -please.specify.valid.principal.name=Please specify valid service principal name -please.specify.valid.principal.password=Please specify valid service principal password -select.domain.search=Select Domain -role.search=Search -list.roles=Enter role name pattern (* for all) -filter.keystore.label=Enter Keystore name pattern (* for all) -filter.keystore.search=Search -filter.keystore.cert.label=Enter Certificate alias pattern (* for all) -filter.keystore.cert.search=Search -security.add.keystores=Add -security.list.keystores=List diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/keystores1.jpg b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/keystores1.jpg deleted file mode 100644 index 3e62a7320dc..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/keystores1.jpg and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/keystores2.jpg b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/keystores2.jpg deleted file mode 100644 index d567896b756..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/keystores2.jpg and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/menu.jpg b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/menu.jpg deleted file mode 100644 index cc84e419cc1..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/menu.jpg and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/usergroups.jpg b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/usergroups.jpg deleted file mode 100644 index 1499dfcb0d3..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/usergroups.jpg and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/users.jpg b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/users.jpg deleted file mode 100644 index 113eaeffa03..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/users.jpg and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/userstores.jpg b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/userstores.jpg deleted file mode 100644 index 9c35169d70a..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/images/userstores.jpg and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-finish-ajaxprocessor.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-finish-ajaxprocessor.jsp deleted file mode 100644 index 101a5dbdec2..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-finish-ajaxprocessor.jsp +++ /dev/null @@ -1,93 +0,0 @@ - -<%@page import="org.apache.axis2.context.ConfigurationContext" %> -<%@page import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.text.MessageFormat" %> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> -<% - String httpMethod = request.getMethod(); - if (!"post".equalsIgnoreCase(httpMethod)) { - response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - return; - } - - String forwardTo = null; - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - Boolean isTrustStore = (Boolean) session.getAttribute("org.wso2.carbon.security.isTrustStore"); - - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - if (request.getParameter("addKeystore") != null || (isTrustStore)) { - String keyStoreName = request.getParameter("keyStoreName"); - try { - String password = request.getParameter("keyPass"); - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - String message = ""; - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - - byte[] content = (byte[]) session.getAttribute("org.wso2.carbon.security.content"); - String fileName = (String) session.getAttribute("org.wso2.carbon.security.fileName"); - String ksPassword = (String) session.getAttribute("org.wso2.carbon.security.ksPassword"); - String provider = (String) session.getAttribute("org.wso2.carbon.security.provider"); - String keystoreType = (String) session.getAttribute("org.wso2.carbon.security.keystoreType"); - - if (isTrustStore) { - message = resourceBundle.getString("truststore.add"); - client.addTrustStore(content, fileName, ksPassword, provider, keystoreType); - } else { - message = resourceBundle.getString("keystore.add"); - client.addKeyStore(content, fileName, ksPassword, provider, keystoreType, password); - } - - forwardTo = "keystore-mgt.jsp?region=region1&item=keystores_menu"; - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request); - - session.setAttribute(SecurityUIConstants.RE_FETCH_KEYSTORES, Boolean.TRUE); - - } catch (Exception e) { - String message = MessageFormat.format(resourceBundle.getString("keystore.cannot.add"), - new Object[]{e.getMessage()}); - forwardTo = "add-keystore-step1.jsp?ordinal=1"; - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - } finally { - - session.removeAttribute("org.wso2.carbon.security.content"); - session.removeAttribute("org.wso2.carbon.security.fileName"); - session.removeAttribute("org.wso2.carbon.security.ksPassword"); - session.removeAttribute("org.wso2.carbon.security.provider"); - session.removeAttribute("org.wso2.carbon.security.keystoreType"); - } - } -%> - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-step1.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-step1.jsp deleted file mode 100644 index f01df846f35..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-step1.jsp +++ /dev/null @@ -1,114 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> - - -<%@ taglib uri="http://www.owasp.org/index.php/Category:OWASP_CSRFGuard_Project/Owasp.CsrfGuard.tld" prefix="csrf" %> - - - - - - -
-

- -
-
- -

- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
* - -
- * - - -
- -
- -
-
- >" type="submit"/> - " type="button" onclick="doCancel();"/> -
-
-
- -
-
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-step2.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-step2.jsp deleted file mode 100644 index 916ab0436a4..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/add-keystore-step2.jsp +++ /dev/null @@ -1,195 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.apache.commons.fileupload.FileItem" %> -<%@ page - import="org.apache.commons.fileupload.disk.DiskFileItem" %> -<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %> -<%@ page import="org.apache.commons.fileupload.servlet.ServletRequestContext" %> -<%@ page - import="org.wso2.carbon.CarbonConstants" %> -<%@ page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> - -<%@page import="org.wso2.carbon.security.ui.jsp.SecurityUIUtil" %> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.util.List" %> -<%@page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> - - - - - - - <% - String forwardTo = null; - boolean isGetPrivateKey = false; - String fileName = null; - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - - try { - - if (ServletFileUpload.isMultipartContent(request)) { - ServletRequestContext servletContext = new ServletRequestContext(request); - List items = SecurityUIUtil.parseRequest(servletContext); - String ksPassword = null; - String provider = null; - String keystoreType = null; - byte[] content = null; - - for (Object item : items) { - DiskFileItem diskFileItem = (DiskFileItem) item; - String name = diskFileItem.getFieldName(); - if (name.equals("keystoreFile")) { - FileItem fileItem = (FileItem) diskFileItem; - fileName = fileItem.getName(); - int index = fileName.lastIndexOf("\\"); - fileName = fileName.substring(index+1); - content = fileItem.get(); - } else if (name.equals("ksPassword")) { - ksPassword = new String(diskFileItem.get()); - } else if (name.equals("provider")) { - provider = new String(diskFileItem.get()); - } else if (name.equals("keystoreType")) { - keystoreType = new String(diskFileItem.get()); - } - } - - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - //client.addKeyStore(content, fileName, ksPassword, provider, keystoreType); - if (client.isPrivateKeyStore(content, ksPassword, keystoreType)) { - isGetPrivateKey = true; - } - - session.setAttribute("org.wso2.carbon.security.content", content); - session.setAttribute("org.wso2.carbon.security.fileName", fileName); - session.setAttribute("org.wso2.carbon.security.ksPassword", ksPassword); - session.setAttribute("org.wso2.carbon.security.provider", provider); - session.setAttribute("org.wso2.carbon.security.keystoreType", keystoreType); - - if (!isGetPrivateKey) { - // Trust stores are assumed to contain only public keys, hence we do not expect a private key - // password for trust stores. - session.setAttribute("org.wso2.carbon.security.isTrustStore", true); - forwardTo = "add-keystore-finish-ajaxprocessor.jsp"; - } else { - //add-keystore-finish.jsp will use this to invoke the correct function and confirmation message - session.setAttribute("org.wso2.carbon.security.isTrustStore", false); - } - - } - } catch (Exception e) { - forwardTo = "add-keystore-step1.jsp?ordinal=1"; - CarbonUIMessage.sendCarbonUIMessage("Error when uploading the KeyStore : " + e.getMessage(), - CarbonUIMessage.ERROR, request); - session.setAttribute("add-keystore-error", "true"); - } - %> - - - - - - - - <% - if (isGetPrivateKey) { - %> - -
-

-
- -

- - - - - - - - - - - - - - -
- - - - - -
* - -
-
- " onclick="history.back()"/> - " onclick="doValidation();"/> - " onclick="doCancel();"/> -
-
-
- <% - }else{ - %> - - - - - <% - } - %> -
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/delete-cert-finish-ajaxprocessor.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/delete-cert-finish-ajaxprocessor.jsp deleted file mode 100644 index 580c70c1214..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/delete-cert-finish-ajaxprocessor.jsp +++ /dev/null @@ -1,68 +0,0 @@ - -<%@page import="org.apache.axis2.context.ConfigurationContext" %> -<%@page import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@page import="java.text.MessageFormat" %> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> -<%@ page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> - -<% - String httpMethod = request.getMethod(); - if (!"post".equalsIgnoreCase(httpMethod)) { - response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - return; - } - - String forwardTo = null; - String keyStore = request.getParameter("keystore"); - String certificateAlias = request.getParameter("alias"); - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - client.removeCertificateFromKeyStore(keyStore, certificateAlias); - session.removeAttribute(SecurityUIConstants.PAGINATED_KEY_STORE_DATA); - String message = resourceBundle.getString("cert.delete"); - forwardTo = "view-keystore.jsp?keyStore=" + Encode.forUriComponent(keyStore); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request); - } catch (Exception e) { - String message = MessageFormat.format(resourceBundle.getString("cert.cannot.delete"), - new Object[]{e.getMessage()}); - forwardTo = "view-keystore.jsp?keyStore=" + Encode.forUriComponent(keyStore); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - } -%> - - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/delete-keystore-finish-ajaxprocessor.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/delete-keystore-finish-ajaxprocessor.jsp deleted file mode 100644 index 36be463eb7f..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/delete-keystore-finish-ajaxprocessor.jsp +++ /dev/null @@ -1,67 +0,0 @@ - -<%@page import="org.apache.axis2.context.ConfigurationContext" %> -<%@page import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.text.MessageFormat" %> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> - -<% - String httpMethod = request.getMethod(); - if (!"post".equalsIgnoreCase(httpMethod)) { - response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - return; - } - - String forwardTo = null; - String keyStore = request.getParameter("keyStore"); - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - client.deleteStore(keyStore); - String message = resourceBundle.getString("keystore.delete"); - forwardTo = "keystore-mgt.jsp"; - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request); - session.setAttribute(SecurityUIConstants.RE_FETCH_KEYSTORES, Boolean.TRUE); - } catch (Exception e) { - String message = MessageFormat.format(resourceBundle.getString("keystore.cannot.delete"), - new Object[]{e.getMessage()}); - forwardTo = "keystore-mgt.jsp"; - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - } -%> - - - - \ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/add.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/add.gif deleted file mode 100644 index 4bfdd7983ec..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/add.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/close.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/close.gif deleted file mode 100644 index d83bac179bf..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/close.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/delete.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/delete.gif deleted file mode 100644 index 471f55c15f6..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/delete.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/edit.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/edit.gif deleted file mode 100644 index 90bd4dce695..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/edit.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/import-cert.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/import-cert.png deleted file mode 100644 index a3d7537b9cc..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/import-cert.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/import.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/import.gif deleted file mode 100644 index 313fe9bf826..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/import.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/keystore.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/keystore.gif deleted file mode 100644 index c57d3bd0866..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/keystore.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/list.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/list.gif deleted file mode 100644 index 638d8ab6ea9..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/list.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/view-keystore.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/view-keystore.png deleted file mode 100644 index 9e66f45ef21..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/view-keystore.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/view.gif b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/view.gif deleted file mode 100644 index 9a1c6e23304..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/images/view.gif and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/import-cert-finish-ajaxprocessor.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/import-cert-finish-ajaxprocessor.jsp deleted file mode 100644 index 6fbeca1dcaa..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/import-cert-finish-ajaxprocessor.jsp +++ /dev/null @@ -1,90 +0,0 @@ - -<%@page import="org.apache.axis2.context.ConfigurationContext" %> -<%@page import="org.apache.commons.fileupload.disk.DiskFileItem" %> -<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %> -<%@page import="org.apache.commons.fileupload.servlet.ServletRequestContext" %> -<%@page import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@page import="org.wso2.carbon.security.ui.jsp.SecurityUIUtil" %> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@page import="java.text.MessageFormat" %> -<%@page import="java.util.List" %> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> -<%@ page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> - -<% - String httpMethod = request.getMethod(); - if (!"post".equalsIgnoreCase(httpMethod)) { - response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - return; - } - - String forwardTo = null; - String keyStore = null; - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - try { - if (ServletFileUpload.isMultipartContent(request)) { - List items = SecurityUIUtil.parseRequest(new ServletRequestContext(request)); - byte[] content = null; - String fileName = null; - for (Object item : items) { - DiskFileItem diskFileItem = (DiskFileItem) item; - String name = diskFileItem.getFieldName(); - if (name.equals("certFile")) { - content = diskFileItem.get(); - fileName = diskFileItem.getName(); - int index = fileName.lastIndexOf("\\"); - fileName = fileName.substring(index+1); - } else if (name.equals("keyStore")) { - keyStore = new String(diskFileItem.get()); - } - } - - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - client.importCertToStore(fileName, content, keyStore); - session.removeAttribute(SecurityUIConstants.PAGINATED_KEY_STORE_DATA); - String message = resourceBundle.getString("cert.import"); - forwardTo = "view-keystore.jsp?keyStore=" + Encode.forUriComponent(keyStore); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request); - } - } catch (Exception e) { - String message = MessageFormat.format(resourceBundle.getString("cert.cannot.import"), - new Object[]{e.getMessage()}); - forwardTo = "import-cert.jsp?keyStore=" + Encode.forUriComponent(keyStore); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - } -%> - - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/import-cert.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/import-cert.jsp deleted file mode 100644 index 7c30ae38505..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/import-cert.jsp +++ /dev/null @@ -1,115 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.wso2.carbon.CarbonConstants" %> -<%@ page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.CertData" %> -<%@page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@ taglib uri="http://www.owasp.org/index.php/Category:OWASP_CSRFGuard_Project/Owasp.CsrfGuard.tld" prefix="csrf" %> -<%@page import="org.wso2.carbon.utils.ServerConstants"%> -<%@ page import="org.owasp.encoder.Encode" %> - - - - - - - - <% - String[] aliasSet = null; - String keyStore = request.getParameter("keyStore"); - KeyStoreData keyStoreData = null; - CertData[] certData = new CertData[0]; - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - ServletContext servletContext = session.getServletContext(); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - keyStoreData = client.getKeystoreInfo(keyStore); - certData = keyStoreData.getCerts(); - } catch (Exception e) { - String message = "Problem while retrieving key store entries"; - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - %> - - - <% - return; - } - %> - - - - -
-

<%= " " + Encode.forHtml(keyStore) %>

-
- - - - - - - - - - - - - - - -
- - - - -
* -
-
- - " onclick="verify();"/> - " onclick="location.href ='keystore-mgt.jsp?region=region1&item=keystores_menu'"/> - " onclick="location.href='view-keystore.jsp?keyStore=<%=Encode.forUriComponent(keyStore) %>'"/> -
- - - -
-
- -
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/keystore-mgt.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/keystore-mgt.jsp deleted file mode 100644 index 2a2d17e8bda..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/keystore-mgt.jsp +++ /dev/null @@ -1,209 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.CarbonError" %> -<%@page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData" %> -<%@page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> -<%@page import="org.wso2.carbon.security.ui.Util" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient"%> -<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="org.owasp.encoder.Encode" %> - - - - - <% - session.removeAttribute(SecurityUIConstants.PAGINATED_KEY_STORE_DATA); - String filter = request.getParameter(SecurityUIConstants.KEYSTORE_LIST_FILTER); - - KeyStoreData[] datas = null; - String paginationValue = "region=region1&item=keystores_menu"; - int numberOfPages = 0; - - String pageNumber = request.getParameter("pageNumber"); - - if (pageNumber == null) { - pageNumber = "0"; - } - - int pageNumberInt = 0; - - try { - pageNumberInt = Integer.parseInt(pageNumber); - } catch (NumberFormatException ignored) { - } - - KeyStoreData[] keyStores = (KeyStoreData[])session.getAttribute(SecurityUIConstants.SESSION_ATTR_KEYSTORES); - - if (filter == null || filter.trim().length() == 0) { - filter = (String) session.getAttribute(SecurityUIConstants.KEYSTORE_LIST_FILTER); - if (filter == null || filter.trim().length() == 0) { - filter = "*"; - } - } - filter = filter.trim(); - session.setAttribute(SecurityUIConstants.KEYSTORE_LIST_FILTER, filter); - - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - - if (keyStores == null || (Boolean)session.getAttribute(SecurityUIConstants.RE_FETCH_KEYSTORES)){ - keyStores = client.getKeyStores(); - session.setAttribute(SecurityUIConstants.SESSION_ATTR_KEYSTORES, keyStores); - session.setAttribute(SecurityUIConstants.RE_FETCH_KEYSTORES, Boolean.FALSE); - } - - KeyStoreData[] filteredKeyStores = Util.doFilter(filter, keyStores); - - if (keyStores != null && keyStores.length > 0) { - numberOfPages = (int) Math.ceil((double) filteredKeyStores.length / SecurityUIConstants.KEYSTORE_DEFAULT_ITEMS_PER_PAGE); - datas = Util.doPaging(pageNumberInt, filteredKeyStores); - } - } catch (Exception e) { - CarbonError error = new CarbonError(); - error.addError(e.getMessage()); - request.getSession().setAttribute(CarbonError.ID, error); - %> - - <% - } - - %> - - - - - - -
-

-
-
- - - - - - - - - - - - -
- - - "/> -
-
-

 

- - - - - - - - - - <% - if (datas != null) { - for (KeyStoreData data : datas) { - if (data != null) { //Confusing!!. Sometimes a null object comes. Maybe a bug in Axis!! - %> - - - - - - <% } - } - %> - -
<%=Encode.forHtmlContent(data.getKeyStoreName())%> - <%=Encode.forHtmlContent(data.getKeyStoreType())%> - - - - - <%if(data.getPubKeyFilePath() != null){ %> - - <%}%> -
- - <% - } - %> -
-
- -
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/view-keystore.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/view-keystore.jsp deleted file mode 100644 index 5306d79b998..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/keystoremgt/view-keystore.jsp +++ /dev/null @@ -1,286 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.wso2.carbon.CarbonConstants" %> -<%@ page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.CertData" %> -<%@ page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.PaginatedCertData" %> -<%@page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.PaginatedKeyStoreData" %> -<%@page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> -<%@page import="org.wso2.carbon.security.ui.Util" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@ page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="org.owasp.encoder.Encode" %> - - - - - - -<% - String filter = request.getParameter(SecurityUIConstants.KEYSTORE_CERT_LIST_FILTER); - PaginatedCertData paginatedCertData = null; - PaginatedCertData paginatedKeyData = null; - CertData[] certData = new CertData[0]; - CertData[] keyData = new CertData[0]; - PaginatedKeyStoreData keyStoreData = (PaginatedKeyStoreData) session.getAttribute(SecurityUIConstants.PAGINATED_KEY_STORE_DATA); - String keyStore = request.getParameter("keyStore"); - String paginationValue = "keyStore=" + keyStore; - if (keyStore == null && keyStoreData != null) { - keyStore = keyStoreData.getKeyStoreName(); - } - int startingPage = 0; - if (keyStoreData != null) { - startingPage = (Integer) session.getAttribute(SecurityUIConstants.STARTING_CERT_DATA_PAGE); - } - - int numberOfPages = 0; - int noOfPageLinksToDisplay = 5; - String pageNumber = request.getParameter("pageNumber"); - if (pageNumber == null) { - pageNumber = "0"; - } - int pageNumberInt = 0; - try { - pageNumberInt = Integer.parseInt(pageNumber); - } catch (NumberFormatException ignored) { - } - - if (filter != null) { - keyStoreData = null; - } - if (filter == null || filter.trim().length() == 0) { - filter = (String) session.getAttribute(SecurityUIConstants.KEYSTORE_CERT_LIST_FILTER); - if (filter == null || filter.trim().length() == 0) { - filter = "*"; - } - } - filter = filter.trim(); - session.setAttribute(SecurityUIConstants.KEYSTORE_CERT_LIST_FILTER, filter); - - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - ServletContext servletContext = session.getServletContext(); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - - if (keyStoreData == null || startingPage + SecurityUIConstants.CACHING_PAGE_SIZE < pageNumberInt || pageNumberInt < startingPage) { - keyStoreData = client.getFilteredPaginatedKeyStoreInfo(keyStore, pageNumberInt, filter); - session.setAttribute(SecurityUIConstants.PAGINATED_KEY_STORE_DATA, keyStoreData); - session.setAttribute(SecurityUIConstants.STARTING_CERT_DATA_PAGE, pageNumberInt); - startingPage = pageNumberInt; - - } - paginatedCertData = keyStoreData.getPaginatedCertData(); - if (paginatedCertData != null && paginatedCertData.getCertDataSet() != null) { - certData = Util.doPaging(pageNumberInt - startingPage, paginatedCertData.getCertDataSet()); - numberOfPages = (int) Math.ceil((double) paginatedCertData.getCertDataSet().length / SecurityUIConstants.DEFAULT_ITEMS_PER_PAGE); - } - - paginatedKeyData = keyStoreData.getPaginatedKeyData(); - if (paginatedKeyData != null && paginatedKeyData.getCertDataSet() != null) { - keyData = Util.doPaging(pageNumberInt - startingPage, paginatedKeyData.getCertDataSet()); - } - - } catch (Exception e) { - -%> -An error occurred! - -

Error message is : <%=Encode.forHtmlContent(e.getMessage())%> -

-<% - - } - -%> - - - -
-

- -
-

- - - - - - - - - - - - - - - - <% - if (keyData != null && keyData.length > 0) { - for (CertData cert : keyData) { - if (cert != null) { - %> - - - - - - - - - - <% - } - } - } - %> - - - - -
<%=Encode.forHtmlContent(cert.getAlias())%> - <%=Encode.forHtmlContent(cert.getIssuerDN())%> - <%=Encode.forHtmlContent(cert.getNotAfter())%> - <%=Encode.forHtmlContent(cert.getNotBefore())%> - <%=cert.getSerialNumber()%> - <%=Encode.forHtmlContent(cert.getSubjectDN())%> - <%=cert.getVersion()%> -
-
- " type="button" - class="button" - onclick="location.href - ='import-cert.jsp?keyStore=<%=Encode.forUriComponent(keyStore)%>'"/> - " type="button" class="button" - onclick="location.href ='keystore-mgt.jsp?region=region1&item=keystores_menu'"/> -
-
-

 

-

-
- - - - - - - - - - - - -
- - - "/> -
-
-

 

- - - - - - - - - - - - - - - <% - if (certData != null && certData.length > 0) { - for (CertData cert : certData) { - if (cert != null) { - %> - - - - - - - - - - - <% - } - } - } - %> - -
<%=Encode.forHtmlContent(cert.getAlias())%> - <%=Encode.forHtmlContent(cert.getIssuerDN())%> - <%=Encode.forHtmlContent(cert.getNotAfter())%> - <%=Encode.forHtmlContent(cert.getNotBefore())%> - <%=cert.getSerialNumber()%> - <%=Encode.forHtmlContent(cert.getSubjectDN())%> - <%=cert.getVersion()%> - Delete -
- -
-
-
diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/security_userguide.html b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/security_userguide.html deleted file mode 100644 index 459584e0fe0..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/security_userguide.html +++ /dev/null @@ -1,75 +0,0 @@ - - - -

Securing a service

-

How to enable security on a service?

-

Steps

-
    -
  1. If you want to use Username Token related security scenarios you must create user groups who are authorized to access the service. User groups can be created from the system-default user store or an external storage. For more details on creating user groups click here
  2. -
  3. If you want to provide X509 related security scenarios, add the trusted certificates to the system. For more details click here
  4. -
  5. Go to the "Service Information" page of the particular service.
  6. -
  7. Click on "Security" link under "Service Management" page.
  8. -
  9. Select "Enable Security" as yes. This will show you a list of available security scenarios.
  10. -
  11. Select the scenario and click on Next. Follow the steps
  12. -
-

How to disable a security of a service?

-

Steps

-
    -
  1. Go to the "Service Information" page of the particular service.
  2. -
  3. Click on "Security" link under "Service Management" page.
  4. -
  5. Select "Enable Security" as No. This will disable security.
  6. -
-

Security Management

-
-Security Management UI -
    -
  • User Management
  • -

    You can add/delete users to the system default user store. Click on change password to change the password of user

    -
  • User Store Management
  • -

    External user stores can be added to the system. External user stores can be either a relational database or a LDAP server.

    -
  • User Group Management
  • -

    Create user groups using the system default user store or from external users stores. When you assign Username Token authentication to services you must select more than -one user groups to authenticate users.

    -

    -
  • Key Store Management
  • -

    Add key stores to the system. When adding trusted certificates you can add the whole trusted certificate store or import your certificates into a key store that is already -existing in the system.

    -
-
-
- -

User Management

-

Users can be added to the system default user store using the UI. Users can be deleted and their passwords can be changed.

-Security Management UI - -

User Store Management

-

The application server can connect to external LDAP servers and JDBC user stores. When creating a connection to external user stores all connection properties must be specified

-Security Management UI - -

User Group Management

-

User groups can be created from external and system-default user stores. A user group can have users from a single user store only. Later on it can be edited to add/remove users.

-Security Management UI -

Key Store Management

-

Key stores can be uploaded to the server.

-Security Management UI -

You also have the option of uploading the trusted certificates to an existing keystore.

-Security Management UI -
- - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/add-security.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/add-security.jsp deleted file mode 100644 index 4742f1d0899..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/add-security.jsp +++ /dev/null @@ -1,117 +0,0 @@ - -<%@page import="org.apache.axis2.context.ConfigurationContext"%> -<%@page import="org.wso2.carbon.CarbonConstants"%> -<%@page import="org.wso2.carbon.security.ui.client.SecurityAdminClient"%> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage"%> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.utils.ServerConstants"%> -<%@page import="java.text.MessageFormat"%> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Map" %> -<%@ page import="java.util.List" %> -<% - String forwardTo = null; - String serviceName = (String) session.getAttribute("serviceName"); - String specificPath = (String) session.getAttribute("returToPath"); - if (specificPath==null) { - specificPath = (String) session.getAttribute("returnToPath"); - } - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - try { - String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - SecurityAdminClient client = new SecurityAdminClient(cookie, backendServerURL, configContext); - - String scenarioId = request.getParameter("scenarioId"); - - String securityCategory = request.getParameter("org.wso2.security.category"); - if (securityCategory != null && securityCategory.equals("kerberos")) { - String servicePrincipalName = request.getParameter("org.wso2.kerberos.service.principal.name"); - String servicePrincipalPassword = request.getParameter("org.wso2.kerberos.service.principal.password"); - - client.applyKerberosSecurity(serviceName, scenarioId, servicePrincipalName, - servicePrincipalPassword); - - } else { - - String policyPath = (String) session.getAttribute("policyPath"); - List userGroupsList = new ArrayList(); - - Map checkBoxMap = (Map) session.getAttribute("checkedRolesMap"); - - String[] userGroupsWithNoPagination = request.getParameterValues("userGroups"); - Map groupsInPage = (Map) session.getAttribute("groupsInPage"); - - if(userGroupsWithNoPagination != null && userGroupsWithNoPagination.length != 0 && groupsInPage != null - && groupsInPage.size() != 0) { - for(String groupName : userGroupsWithNoPagination) { - groupsInPage.put(groupName.toLowerCase(), true); - } - } - - if(groupsInPage != null && groupsInPage.size() != 0) { - for (Map.Entry entry : groupsInPage.entrySet()) { - checkBoxMap.put(entry.getKey(), entry.getValue()); - } - } - - for (Map.Entry entry : checkBoxMap.entrySet()) { - if (entry.getValue().equals(Boolean.TRUE)) { - userGroupsList.add(entry.getKey()); - } - } - String[] userGroups = new String[userGroupsList.size()]; - userGroups = userGroupsList.toArray(userGroups); - String privateStore = request.getParameter("privateStore"); - String[] trustedStores = request.getParameterValues("trustStore"); - client.applySecurity(serviceName, scenarioId, policyPath, trustedStores, privateStore, userGroups); - - } - - String message = resourceBundle.getString("security.add"); - forwardTo = "../service-mgt/service_info.jsp?serviceName=" + serviceName; - - if (specificPath!=null && specificPath.trim().length()>0){ - forwardTo = specificPath +"?serviceName=" + Encode.forUriComponent(serviceName); - session.removeAttribute("returToPath"); - } - - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request); - } catch (Exception e) { - String message = MessageFormat.format(resourceBundle.getString("security.cannot.add"), - new Object[]{e.getMessage()}); - forwardTo = "index.jsp?ordinal=2&serviceName=" + Encode.forUriComponent(serviceName); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - } - -%> - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/extensions/js/vui.js b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/extensions/js/vui.js deleted file mode 100644 index a7755eb6333..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/extensions/js/vui.js +++ /dev/null @@ -1,92 +0,0 @@ -/*all validation functions required by the .jsp files*/ - -function validateEmpty(fldname) { - var fld = document.getElementsByName(fldname)[0]; - var error = ""; - var value = fld.value; - if (value.length == 0) { - error = fld.name+" "; - return error; - } - - value = value.replace(/^\s+/, "") ; - if (value.length == 0) { - error = fld.name + "(contains only spaces) "; - return error; - } - - return error; -} - -function validateName(fldname) { - var invalid = " "; // Invalid character is a space - var fld = document.getElementsByName(fldname)[0]; - var error = ""; - var value = fld.value; - - if (value.indexOf(invalid) > -1) { - error = fld.name; - } - return error; -} - -function isAtleastOneCheckedIfExisting(fldname){ - var foundOne = false; - var elems = document.getElementsByName(fldname); - - if(elems.length == 0){ - foundOne = true; - }else{ - var counter=0; - for (counter=0; counter < elems.length; counter++) { - if(elems[counter].checked == true) - foundOne= true; - } - } - return foundOne; -} - -function isAtleastOneChecked(fldname){ - var foundOne = null; - var elems = document.getElementsByName(fldname); - - var counter=0; - for (counter=0; counter < elems.length; counter++) { - if(elems[counter].checked == true) - foundOne= elems[counter].value; - } - return foundOne; -} - -function validatePassword(fld1name , fld2name){ - var error = ""; - var invalid = " "; // Invalid character is a space - var minLength = 6; // Minimum length - var pw1 = document.getElementsByName(fld1name)[0].value; - var pw2 = document.getElementsByName(fld2name)[0].value; - // check for a value in both fields. - if (pw1 == '' || pw2 == '') { - error = 'Please enter the password twice.'; - return error; - } - - // check for minimum length - if (pw1.length < minLength) { - error = 'Your password must be at least ' + minLength + ' characters long. Try again.'; - return error; - } - - // check for spaces - if (pw1.indexOf(invalid) > -1) { - error = "Sorry, spaces are not allowed."; - return error; - } - - - if (pw1 != pw2) { - error = "You did not enter the same password twice. Please re-enter your password."; - return error; - } - - return error; -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario1.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario1.png deleted file mode 100644 index 98650554452..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario1.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario10.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario10.png deleted file mode 100644 index f5d532708c4..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario10.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario11.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario11.png deleted file mode 100644 index c802d2330ec..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario11.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario12.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario12.png deleted file mode 100644 index 552b045b101..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario12.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario13.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario13.png deleted file mode 100644 index eea4042dd82..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario13.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario14.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario14.png deleted file mode 100644 index 3cb7ea6c1a3..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario14.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario15.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario15.png deleted file mode 100644 index f96dd3ca876..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario15.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario16.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario16.png deleted file mode 100644 index 609586156fc..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario16.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario2.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario2.png deleted file mode 100644 index 751aa5d55bb..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario2.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario3.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario3.png deleted file mode 100644 index 2c156a2e8f3..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario3.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario4.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario4.png deleted file mode 100644 index 952e6a6d2c8..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario4.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario5.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario5.png deleted file mode 100644 index 6e2b1b180ce..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario5.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario6.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario6.png deleted file mode 100644 index 6dc2b623321..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario6.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario7.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario7.png deleted file mode 100644 index df3876bbd41..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario7.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario8.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario8.png deleted file mode 100644 index e2accbd4c43..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario8.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario9.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario9.png deleted file mode 100644 index c58d6831a16..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/scenario9.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/view.png b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/view.png deleted file mode 100644 index 2fbe1954897..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/images/view.png and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/index.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/index.jsp deleted file mode 100644 index 287af4321a4..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/index.jsp +++ /dev/null @@ -1,435 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@page import="org.apache.axis2.context.ConfigurationContext" %> -<%@page - import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityScenarioData" %> -<%@page import="org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityScenarioDataWrapper" %> -<%@page import="org.wso2.carbon.security.ui.client.SecurityAdminClient" %> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@ page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.text.MessageFormat" %> - - -<%@page import="java.util.ResourceBundle"%> -<%@ page import="org.owasp.encoder.Encode" %> - - - - - - - - - - - - - - - - -<% - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - String[] options = new String[]{"Yes", "No"}; - String[] optionsValues = new String[]{resourceBundle.getString("yes"), resourceBundle.getString("no")}; - String backLink = (String)session.getAttribute("backLink"); -%> -<%! - String info = null; - SecurityScenarioData[] scenarios = null; -%> -<%! - String showOption = null; - String displayStyle = null; - int[] optionsOrder = null; - -%> - - -<% - SecurityScenarioData currentScenario; - String serviceName; - String policyPath = ""; - serviceName = request.getParameter("serviceName"); - if (serviceName != null) { - serviceName = serviceName.trim(); - if (serviceName.length() > 0) { - session.setAttribute("serviceName", serviceName); - } - } else { - serviceName = (String) session.getAttribute("serviceName"); - } - - if (serviceName == null) { - String message = resourceBundle.getString("cannot.proceed.please.select.a.service.to.enable.security"); - CarbonUIMessage uiMsg = new CarbonUIMessage(message, CarbonUIMessage.ERROR, null); - session.setAttribute(CarbonUIMessage.ID, uiMsg); - %> - - <% - return; - } - - if (backLink==null){ - backLink = "../service-mgt/service_info.jsp?serviceName="+ Encode.forUriComponent(serviceName); - } - - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - SecurityAdminClient client = new SecurityAdminClient(cookie, backendServerURL, configContext); - SecurityScenarioDataWrapper scenarioDataWrapper = client.getScenarios(serviceName); - scenarios = scenarioDataWrapper.getScenarios(); - currentScenario = scenarioDataWrapper.getCurrentScenario(); - - if (currentScenario == null) { - info = MessageFormat.format(resourceBundle.getString("service.not.secured"), - serviceName); - optionsOrder = new int[]{1, 0}; - displayStyle = "display: none;"; - } else { - if (currentScenario.getPolicyRegistryPath() != null) { - policyPath = currentScenario.getPolicyRegistryPath(); - info = MessageFormat.format(resourceBundle.getString("service.secured.using.policy.from.registry"), - serviceName); - } else { - info = MessageFormat.format(resourceBundle.getString("service.secured.using"), - serviceName, currentScenario.getSummary()); - } - optionsOrder = new int[]{0, 1}; - displayStyle = "display: inline;"; - } - } catch (Exception e) { - CarbonUIMessage uiMsg = new CarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR, e); - session.setAttribute(CarbonUIMessage.ID, uiMsg); -%> - -<% - return; - } -%> - - - - -
-

- -
-

<%=Encode.forHtmlContent(info)%>

- -

 

- - - - - - -
- - - -
-

 

- -
- - - - -
- " onclick="location.href = '<%=backLink%>'"> -
-

 

-
- -
-
- - - - - - - - - - - <% - int scenarioIdDisplay = 1; - for (SecurityScenarioData scenario : scenarios) { - if (scenario != null) { - String id = scenario.getScenarioId(); - if (!scenario.getType().equals("basic")){ - continue; - } - //checkScenarioID(scenarioIdDisplay, scenario); - %> - - - - - - - - <% - } - } - %> - - - - - <% - for (SecurityScenarioData scenario: scenarios) { - if (scenario != null) { - String id = scenario.getScenarioId(); - if (!scenario.getType().equals("advanced")) { - continue; - } - //checkScenarioID(scenarioIdDisplay, scenario); - %> - - - - - - - - <% - } - } - %> - - - - - - - - - - - - - - -
<%= scenarioIdDisplay++ %>. - <% - int helpId = scenarioIdDisplay - 1; - if (currentScenario != null && "".equals(policyPath) && - currentScenario.getScenarioId().equals(id)) { - %><% - } else { - %><% - } - %> - - - - - <%=Encode.forHtmlContent(scenario.getDescription())%> -
 
<%= scenarioIdDisplay++ %>. - <% - int helpId = scenarioIdDisplay - 1; - if (currentScenario != null && "".equals(policyPath) && - currentScenario.getScenarioId().equals(id)) { - %><% - } else { - %><% - } - %> - - - - <%=Encode.forHtmlContent(scenario.getDescription())%> -
 
  - <% if (!"".equals(policyPath)) { %> - - <% } else { %> - - <% } %> - - - - -
- - - - - - -
- <% if (!"".equals(policyPath)) { %> - - <% } else { %> - - <% } %> - - - - -
-
-
- " - onclick="location.href = '<%= Encode.forJavaScriptBlock(backLink)%>'"> - >"/> -
-
-
- - -
-
-
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/remove-security.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/remove-security.jsp deleted file mode 100644 index d680259a5ba..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/remove-security.jsp +++ /dev/null @@ -1,67 +0,0 @@ - -<%@page import="org.apache.axis2.context.ConfigurationContext"%> -<%@page import="org.wso2.carbon.CarbonConstants"%> -<%@page import="org.wso2.carbon.security.ui.client.SecurityAdminClient"%> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage"%> -<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<% - String httpMethod = request.getMethod(); - if (!"post".equalsIgnoreCase(httpMethod)) { - response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - return; - } - - String forwardTo = null; - String serviceName = (String) session.getAttribute("serviceName"); - String keyStore = request.getParameter("keyStore"); - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - try { - String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - SecurityAdminClient client = new SecurityAdminClient(cookie, backendServerURL, configContext); - client.disableSecurityOnService(serviceName); - //TODO clear session params here - String message = resourceBundle.getString("security.disable"); - forwardTo = "index.jsp?serviceName=" + Encode.forUriComponent(serviceName); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request); - } catch (Exception e) { - String message = MessageFormat.format(resourceBundle.getString("security.cannot.disable"), - new Object[]{e.getMessage()}); - - forwardTo = "index.jsp?serviceName=" + Encode.forUriComponent(serviceName); - CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request); - } -%> - -<%@page import="org.wso2.carbon.utils.ServerConstants"%> -<%@page import="java.text.MessageFormat"%> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/ut-ks-advance.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/ut-ks-advance.jsp deleted file mode 100644 index c02d642c60d..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/ut-ks-advance.jsp +++ /dev/null @@ -1,688 +0,0 @@ - -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<%@ taglib uri="http://www.owasp.org/index.php/Category:OWASP_CSRFGuard_Project/Owasp.CsrfGuard.tld" prefix="csrf" %> -<%@page import="org.apache.axis2.context.ConfigurationContext" %> -<%@page import="org.wso2.carbon.CarbonConstants" %> -<%@page import="org.wso2.carbon.identity.sts.common.stub.config.xsd.KerberosConfigData" %> -<%@page import="org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityConfigData" %> -<%@page import="org.wso2.carbon.identity.sts.common.stub.config.xsd.SecurityScenarioData" %> -<%@page import="org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData" %> -<%@page import="org.wso2.carbon.security.ui.SecurityUIConstants" %> -<%@page import="org.wso2.carbon.security.ui.Util" %> -<%@page import="org.wso2.carbon.security.ui.client.KeyStoreAdminClient" %> -<%@ page import="org.wso2.carbon.security.ui.client.SecurityAdminClient" %> -<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@page import="org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName" %> -<%@ page import="org.wso2.carbon.user.mgt.stub.types.carbon.UserRealmInfo" %> -<%@page import="org.wso2.carbon.user.mgt.ui.UserAdminClient" %> - - -<%@page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.text.MessageFormat" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Arrays" %> -<%@ page import="java.util.List" %> -<%@ page import="java.util.ResourceBundle" %> -<%@ page import="org.owasp.encoder.Encode" %> -<%@ page import="java.util.HashMap" %> -<%@ page import="java.util.Map" %> - - - - - - - - - -<% - FlaggedName[] groupData = null; - KeyStoreData[] datas = null; - String curr_pvtks = ""; - List curr_tstks = new ArrayList(); - List curr_ugs = new ArrayList(); - String category = null; - boolean isPolicyFromRegistry = false; - boolean fault = false; - UserAdminClient userAdminClient = null; - String[] domainNames = null; - boolean newFilter = false; - UserRealmInfo userRealmInfo = null; - userRealmInfo = (UserRealmInfo) session.getAttribute(SecurityUIConstants.USER_STORE_INFO); - - String cancelLink = (String)session.getAttribute("cancelLink"); - - int noOfPageLinksToDisplay = 5; - String pageNumber; - - if (request.getParameter("pageNumber") == null) { - session.removeAttribute("checkedRolesMap"); - } - if (session.getAttribute("checkedRolesMap") == null) { - session.setAttribute("checkedRolesMap", new HashMap()); - } - - // search filter - String selectedDomain = request.getParameter("domain"); - if(selectedDomain == null || selectedDomain.trim().length() == 0){ - selectedDomain = (String) session.getAttribute(SecurityUIConstants.ROLE_LIST_DOMAIN_FILTER); - if (selectedDomain == null || selectedDomain.trim().length() == 0) { - selectedDomain = SecurityUIConstants.ALL_DOMAINS; - } - } else { - newFilter = true; - } - - session.setAttribute(SecurityUIConstants.ROLE_LIST_DOMAIN_FILTER, selectedDomain.trim()); - - String filter = request.getParameter(SecurityUIConstants.ROLE_LIST_FILTER); - if (filter == null || filter.trim().length() == 0) { - filter = (String) session.getAttribute(SecurityUIConstants.ROLE_LIST_FILTER); - if (filter == null || filter.trim().length() == 0) { - filter = "*"; - } - } else { - if(filter.contains(SecurityUIConstants.DOMAIN_SEPARATOR)){ - selectedDomain = SecurityUIConstants.ALL_DOMAINS; - session.removeAttribute(SecurityUIConstants.ROLE_LIST_DOMAIN_FILTER); - } - newFilter = true; - } - - - String modifiedFilter = filter.trim(); - if(!SecurityUIConstants.ALL_DOMAINS.equalsIgnoreCase(selectedDomain)){ - modifiedFilter = selectedDomain + SecurityUIConstants.DOMAIN_SEPARATOR + filter; - modifiedFilter = modifiedFilter.trim(); - } - - session.setAttribute(SecurityUIConstants.ROLE_LIST_FILTER, filter.trim()); - - - int numberOfPages = 0; - String isPaginatedString = request.getParameter("isPaginated"); - if (isPaginatedString != null && isPaginatedString.equals("true")) { - userAdminClient = (UserAdminClient) session.getAttribute(SecurityUIConstants.USER_ADMIN_CLIENT); - numberOfPages = (Integer) session.getAttribute(SecurityUIConstants.FLAGGED_NAME_PAGE_COUNT); - } - String paginationValue = "isPaginated=true"; - - - pageNumber = request.getParameter("pageNumber"); - if (pageNumber == null) { - pageNumber = "0"; - } - int pageNumberInt = 0; - try { - pageNumberInt = Integer.parseInt(pageNumber); - } catch (NumberFormatException ignored) { - } - - String serviceName = (String) session.getAttribute("serviceName"); - - String BUNDLE = "org.wso2.carbon.security.ui.i18n.Resources"; - ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale()); - String info = MessageFormat.format(resourceBundle.getString("service.secured.using.a.default.scenario"), serviceName); - - String scenId = request.getParameter("scenarioId"); - String registryPolicyPath = null; - if ("policyFromRegistry".equals(scenId)) { - isPolicyFromRegistry = true; - registryPolicyPath = request.getParameter("secPolicyRegText"); - info = MessageFormat.format(resourceBundle.getString("service.secured.using.custom.policy.select.users.and.key.stores"), serviceName); - } - if (scenId != null) { - session.setAttribute("scenarioId", scenId); - } else { - /** - * This is needed for proper functionality of breadcrumbs. If the user goes - * forward and clicks on "Activate Security" breadcrumb, scenario Id can only - * be accessed from the session. - */ - scenId = (String) session.getAttribute("scenarioId"); - } - - /** - * FIX for https://wso2.org/jira/browse/IDENTITY-4550 - * When securing a service using a policy from registry we select the policyPath by browsing the registry, - * but once we try to select roles by searching in the next step, the page gets refreshed and the set policyPath - * is lost. Therefore we need to put the policyPath in the session and retrieve from it. - */ - if (registryPolicyPath != null) { - session.setAttribute("policyPath", registryPolicyPath); - } else { - registryPolicyPath = (String) session.getAttribute("policyPath"); - } - - - boolean kerberosScenario = false; - KerberosConfigData kerberosConfigData = null; - - if (cancelLink==null){ - cancelLink = "../service-mgt/service_info.jsp?serviceName="+ Encode.forUriComponent(serviceName); - } - - try { - String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = - (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - SecurityAdminClient secClient = new SecurityAdminClient(cookie, backendServerURL, configContext); - SecurityScenarioData scenData = secClient.getSecurityScenario(scenId); - - SecurityConfigData configData = secClient.getSecurityConfigData(serviceName, scenId, registryPolicyPath); - category = scenData.getCategory(); - - //place holders for existing configs - if (configData != null) { - if (configData.getPrivateStore() != null) { - curr_pvtks = configData.getPrivateStore(); - } - - if (configData.getTrustedKeyStores() != null && - configData.getTrustedKeyStores().length > 0 && - configData.getTrustedKeyStores()[0] != null) { - curr_tstks = Arrays.asList(configData.getTrustedKeyStores()); - } - - if (configData.getUserGroups() != null && - configData.getUserGroups().length > 0 && - configData.getUserGroups()[0] != null) { - curr_ugs = Arrays.asList(configData.getUserGroups()); - } - - - Map checkBoxMap = (Map) session.getAttribute("checkedRolesMap"); - if (checkBoxMap.size() == 0) { - for (String curr_role : curr_ugs) { - checkBoxMap.put(curr_role.toLowerCase(), true); - } - session.removeAttribute("checkedRolesMap"); - session.setAttribute("checkedRolesMap", checkBoxMap); - } - - if (category.contains("kerberos")) { - kerberosConfigData = configData.getKerberosConfigurations(); - } - } - - if (category.contains("ut")) { - if (userAdminClient == null) { - int itemsPerPageInt = SecurityUIConstants.DEFAULT_ITEMS_PER_PAGE; - userAdminClient = new UserAdminClient(cookie, backendServerURL, configContext); - userRealmInfo = userAdminClient.getUserRealmInfo(); - numberOfPages = (int) Math.ceil((double) userAdminClient.getAllRolesNames(modifiedFilter, -1).length / itemsPerPageInt); - session.setAttribute(SecurityUIConstants.USER_ADMIN_CLIENT, userAdminClient); - session.setAttribute(SecurityUIConstants.FLAGGED_NAME_PAGE_COUNT, numberOfPages); - session.setAttribute(SecurityUIConstants.USER_STORE_INFO, userRealmInfo); - - - } - groupData = Util.doFlaggedNamePaging(pageNumberInt, userAdminClient.getAllRolesNames(modifiedFilter, -1)); - - if(userRealmInfo != null){ - domainNames = userRealmInfo.getDomainNames(); - if(domainNames != null){ - List list = new ArrayList(Arrays.asList(domainNames)); - list.add(SecurityUIConstants.ALL_DOMAINS); - domainNames = list.toArray(new String[list.size()]); - } - } - - } - - if (category.contains("keystore")) { - KeyStoreAdminClient client = new KeyStoreAdminClient(cookie, backendServerURL, configContext); - datas = client.getKeyStores(); - } - - if (category.contains("kerberos")) { - kerberosScenario = true; - } - - } catch (Exception e) { - fault = true; - CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR, request, e); -%> - -<% - } - if (!fault) { -%> -
-

- -
-

<%=Encode.forHtmlAttribute(info)%> -

- -

 

-<% - if (category.contains("ut")) { -%> - -
- - - - - - - - <% - if (domainNames != null && domainNames.length > 0) { - %> - - - - - <% - } - %> - - - - - - - -
-
- - - "/> -
-
-<% - } -%> -
- - -<% - if (category.contains("ut")) { -%> - - - - - - - - - - - -
- - <% - if (groupData != null) { - if(session.getAttribute("groupsInPage") != null) { - session.removeAttribute("groupsInPage"); - } - Map groupsInPage = new HashMap(); - - for (FlaggedName data : groupData) { - if (data != null) { //Confusing!!. Sometimes a null object comes. Maybe a bug in Axis!! - - groupsInPage.put(data.getItemName().toLowerCase(), false); - - if (CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME.equals(data.getItemName())) { - continue; - } - - String checked = ""; - if (session.getAttribute("checkedRolesMap") != null && - ((Map) session.getAttribute("checkedRolesMap")).get(data.getItemName().toLowerCase()) != null && - ((Map) session.getAttribute("checkedRolesMap")).get(data.getItemName().toLowerCase()) == true) { - checked = "checked=\"checked\""; - } - %> - - - - <% - } - } - session.setAttribute("groupsInPage", groupsInPage); - } - %> -
/> <%=Encode.forHtmlContent(data.getItemName())%> -
-
- <% - } - %> - - - -<% - - if (category.contains("keystore")) { -%> - - - - - - - - - - - -
- - <% - if (datas != null) { - for (KeyStoreData data : datas) { - if (data != null) { //Confusing!!. Sometimes a null object comes. Maybe a bug in Axis!! - - String checked = ""; - if (curr_tstks.contains(data.getKeyStoreName())) { - checked = "checked=\"checked\""; - } - %> - - - - <% - } - } - } - %> -
/> - <%=Encode.forHtmlContent(data.getKeyStoreName())%> -
-
- - - - - - - - - - - -
- - - - -
- -
-
-<% - } -%> - - -<% - if (category.contains("kerberos")) { - - String servicePrincipleName = ""; - String servicePrinciplePassword = ""; - if (kerberosConfigData != null) { - - servicePrincipleName = kerberosConfigData.getServicePrincipleName(); - servicePrinciplePassword = kerberosConfigData.getServicePrinciplePassword(); - } -%> - - - - - - - - - - - - -
- - - - - - - - - - -
- * - - -
- * - - -
-
- - -<% - } -%> - - -

- - - - -
- " - onclick="location.href = 'index.jsp?serviceName=<%=Encode.forUriComponent(serviceName)%>'"/> - "/> - " - onclick="location.href = '<%=Encode.forJavaScriptBlock(cancelLink)%>'"/> -
-<% - -%> - -
-
-<% - - Map checkBoxMap = (Map) session.getAttribute("checkedRolesMap"); - String selectedBoxesStr = request.getParameter("selectedRoles"); - String unselectedBoxesStr = request.getParameter("unselectedRoles"); - String regex = ":"; - - if (selectedBoxesStr != null || unselectedBoxesStr != null) { - if (selectedBoxesStr != null && !selectedBoxesStr.equals("")) { - String[] selectedBoxes = selectedBoxesStr.split(regex); - for (String selectedBox : selectedBoxes) { - checkBoxMap.put(selectedBox.toLowerCase(), true); - } - } - if (unselectedBoxesStr != null && !unselectedBoxesStr.equals("")) { - String[] unselectedBoxes = unselectedBoxesStr.split(regex); - for (String unselectedBox : unselectedBoxes) { - checkBoxMap.put(unselectedBox.toLowerCase(), false); - } - } - } - session.removeAttribute("checkedRolesMap"); - session.setAttribute("checkedRolesMap", checkBoxMap); - } -%> - - - -
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/view-scenario-detail_ajaxprocessor.jsp b/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/view-scenario-detail_ajaxprocessor.jsp deleted file mode 100644 index 7ffad07c75f..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt.ui/src/main/resources/web/securityconfig/view-scenario-detail_ajaxprocessor.jsp +++ /dev/null @@ -1,38 +0,0 @@ -<%@ page import="org.owasp.encoder.Encode" %> - -<% - String scenarioIdNumber = ""; - String scenarioId = request.getParameter("scenarioId"); - try { - Integer.parseInt(scenarioId); - scenarioIdNumber = "scenario" + scenarioId; - } catch (Exception e) { - //scenarioId should be an integer. - scenarioId = null; - } - String scenarioSummary = request.getParameter("scenarioSummary"); -%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - -
-

<%=Encode.forHtml(scenarioId)%> : <%=Encode.forHtml(scenarioSummary)%>

- security scenario description -
-
\ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/pom.xml b/components/security-mgt/org.wso2.carbon.security.mgt/pom.xml deleted file mode 100644 index 17be66aaadd..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/pom.xml +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - security-mgt - 5.25.293-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.security.mgt - bundle - WSO2 Carbon - Security BE - A custom wso2 products or solution - http://wso2.org - - - - org.wso2.orbit.org.apache.neethi - neethi - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.registry.core - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon - javax.cache.wso2 - - - backport-util-concurrent.wso2 - backport-util-concurrent - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.base - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.core - - - - org.testng - testng - test - - - org.jacoco - org.jacoco.agent - runtime - test - - - org.slf4j - slf4j-api - test - - - org.mockito - mockito-core - test - - - org.powermock - powermock-api-mockito2 - test - - - org.powermock - powermock-module-testng - test - - - org.jmockit - jmockit - test - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.testutil - test - - - org.wso2.orbit.javax.xml.bind - jaxb-api - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${project.artifactId}-${project.version} - - org.wso2.carbon.security.internal, - - - javax.cache, - javax.security.auth.callback, - javax.servlet.http; version="${imp.pkg.version.javax.servlet}", - javax.xml.namespace, - javax.xml.stream; version="${equinox.osgi.stax-api.imp.pkg.version.range}", - javax.xml.bind, - javax.xml.bind.annotation, - org.w3c.dom, - org.jaxen; version="${axiom.org.jaxen.imp.pkg.version.range}", - - org.apache.axiom.*; version="${axiom.osgi.version.range}", - org.apache.axis2.*; version="${axis2.osgi.version.range}", - org.apache.neethi; version="${neethi.osgi.version.range}", - org.apache.neethi.builders.xml; version="${neethi.osgi.version.range}", - org.apache.commons.logging; version="${import.package.version.commons.logging}", - org.apache.commons.collections; version="${commons-collections.wso2.osgi.version.range}", - org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}", - - org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}", - org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}", - - org.wso2.carbon; version="${carbon.kernel.package.import.version.range}", - org.wso2.carbon.utils.*;version="${carbon.kernel.package.import.version.range}", - org.wso2.carbon.context; version="${carbon.kernel.package.import.version.range}", - org.wso2.carbon.core.*;version="${carbon.kernel.package.import.version.range}", - org.wso2.carbon.user.core.*;version="${carbon.kernel.package.import.version.range}", - - org.wso2.carbon.base; version="${carbon.base.imp.pkg.version.range}", - org.wso2.carbon.user.api; version="${carbon.user.api.imp.pkg.version.range}", - org.wso2.carbon.registry.core.*;version="${carbon.kernel.registry.imp.pkg.version}", - org.wso2.carbon.registry.api;version="${carbon.kernel.registry.imp.pkg.version}", - org.wso2.carbon.identity.core.*; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.base; version="${carbon.identity.package.import.version.range}" - - - !org.wso2.carbon.security.internal, - org.wso2.carbon.security.*; version="${carbon.identity.package.export.version}", - - org.apache.axis2.engine.AxisObserver - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.plugin.version} - - - src/test/resources/testng.xml - - - org.ops4j.pax.logging - org.wso2.org.ops4j.pax.logging - - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - - - **/*Exception.class - **/IdentityConstants*.class - **/UserMgtInitializer.class - **/UserMgtDSComponent.class - - - - - default-prepare-agent - - prepare-agent - - - - default-prepare-agent-integration - - prepare-agent-integration - - - - default-report - - report - - - - default-report-integration - - report-integration - - - - default-check - - check - - - - - BUNDLE - - - COMPLEXITY - COVEREDRATIO - - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - true - - - - org.codehaus.mojo - findbugs-maven-plugin - - true - - - - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityConfigException.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityConfigException.java deleted file mode 100644 index d08f7a1f705..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityConfigException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security; - -import org.wso2.carbon.identity.base.IdentityException; - -public class SecurityConfigException extends IdentityException { - - private static final long serialVersionUID = 2202942561393644426L; - - public SecurityConfigException(String message, Throwable cause) { - super(message, cause); - } - - public SecurityConfigException(String message) { - super(message); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityConstants.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityConstants.java deleted file mode 100644 index 4f50c249076..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityConstants.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security; - -import org.wso2.carbon.core.RegistryResources; - -import javax.xml.namespace.QName; - -public class SecurityConstants { - - public static final String SECURITY_NAMESPACE = "http://www.wso2.org/products/carbon/security"; - public static final QName SUMMARY_QN = new QName(SECURITY_NAMESPACE, "Summary"); - public static final QName DESCRIPTION_QN = new QName(SECURITY_NAMESPACE, "Description"); - public static final QName ID_QN = new QName("id"); - public static final QName CATEGORY_QN = new QName(SECURITY_NAMESPACE, "Category"); - public static final QName MODULES_QN = new QName(SECURITY_NAMESPACE, "Modules"); - public static final QName WSUID_QN = new QName(SECURITY_NAMESPACE, "WsuId"); - public static final QName TYPE_QN = new QName(SECURITY_NAMESPACE, "Type"); - public static final QName IS_GEN_POLICY_QN = new QName(SECURITY_NAMESPACE, "isGeneralPolicy"); - - //Resources - public static final String SECURITY_POLICY = RegistryResources.COMPONENTS - + "org.wso2.carbon.security.mgt/policy"; - - //Basic scenarios - public static final String CUSTOM_SECURITY_SCENARIO = "customScenario"; - public static final String USERNAME_TOKEN_SCENARIO_ID = "scenario1"; - public static final String CONFIDENTIALITY_SCENARIO_ID = "scenario5"; - public static final String INTEGRITY_SCENARIO_ID = "scenario4"; - public static final String NONREPUDIATION_SCENARIO_ID = "scenario2"; - public static final String SCENARIO_DISABLE_SECURITY = "DisableSecurity"; - public static final String POLICY_FROM_REG_SCENARIO = "policyFromRegistry"; - - public static final String CUSTOM_SECURITY_SCENARIO_SUMMARY = "Custom security policy"; - - public static final String ALLOW_ROLES_PROXY_PARAM_NAME = "allowRoles"; - - public static final String PROP_USER_STORE = "service.userstore"; - - public static final String EMPTY_SERVICE_VERSION = "SNAPSHOT"; - public static final String EMPTY_MODULE_VERSION = "SNAPSHOT"; - - public static final String RAMPART_MODULE_NAME = "rampart"; - public static final String ASSOCIATION_TRUSTED_KEYSTORE = "trusted-keystore"; - public static final String ASSOCIATION_PRIVATE_KEYSTORE = RegistryResources.Associations.PRIVATE_KEYSTORE; - public static final String ASSOCIATION_SERVICE_SECURING_POLICY = "service-secpolicy"; - public static final String ASSOCIATION_STORE_TYPE = "service-secpolicy"; - - public static final String USER = "rampart.config.user"; - - public static final String HTTPS_TRANSPORT = "https"; - - public static final String KEY_STORES = RegistryResources.SecurityManagement.KEY_STORES; - //properties - public static final String PROP_ROLE = RegistryResources.SecurityManagement.PROP_ROLE; - public static final String PROP_PASSWORD = RegistryResources.SecurityManagement.PROP_PASSWORD; - public static final String PROP_TYPE = RegistryResources.SecurityManagement.PROP_TYPE; - public static final String PROP_USERS = RegistryResources.SecurityManagement.PROP_USERS; - public static final String PROP_PRIVATE_KEY_ALIAS = RegistryResources.SecurityManagement.PROP_PRIVATE_KEY_ALIAS; - public static final String PROP_PRIVATE_KEY_PASS = RegistryResources.SecurityManagement.PROP_PRIVATE_KEY_PASS; - public static final String PROP_DESCRIPTION = "description"; - public static final String PROP_AUTHENTICATOR_CLASS = "class"; - public static final String PROP_INTERNAL = "internal"; - public static final String PROP_PROVIDER = "provider"; - public static final String PROP_SELECT_ALL = "selectAll"; - public static final String PROP_RAHAS_SCT_ISSUER = "rahas.sctissuer"; - public static final String PROP_TENANT_PUB_KEY_FILE_NAME_APPENDER = "tenant.pub.key.file.name.appender"; - //associations - public static final String ASSOCIATION_STORE_GROUP = RegistryResources.SecurityManagement.ASSOCIATION_STORE_GROUP; - public static final String ASSOCIATION_TENANT_KS_PUB_KEY = "assoc.tenant.ks.pub.key"; - public static final String DEFAULT_STORE = RegistryResources.SecurityManagement.DEFAULT_STORE; - public static final String ADMIN_USER = "admin"; - public static final String ADMIN_GROUP = "admin-group"; - // registry identifiers - public static final String CONFIG_REGISTRY_IDENTIFIER = "conf"; - public static final String GOVERNANCE_REGISTRY_IDENTIFIER = "gov"; - public static final String SECURITY_POLICY_PATH = "secPolicyRegistryPath"; - public static final int MAX_USER_COUNT = 50; - public static final String WS_SEC_UTILITY_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-" + - "200401-wss-wssecurity-utility-1.0.xsd"; - public static final String POLICY_ID = "Id"; - public static final QName POLICY_ID_QNAME = new QName(WS_SEC_UTILITY_NS, POLICY_ID); - public static final int DEFAULT_ITEMS_PER_PAGE = 50; - public static final int ITEMS_PER_PAGE = 10; - public static final int CACHING_PAGE_SIZE = 5; - //AxisService parameter names - public static final String SCENARIO_ID_PARAM_NAME = "ScenarioID"; - public static final String SCENARIO_ID_SET_PARAM_NAME = "ScenarioIDSet"; - public static final String ROLE_ADMIN = RegistryResources.SecurityManagement.ADMIN_ROLE; - public static final String ROLE_GENERAL = "General User"; - - public static final String TRUST_MODULE = "rahas"; - public static final String ALLOWED_ROLES_PARAM_NAME = "org.wso2.carbon.security.allowedroles"; - - // Constants related to security policy parts - public static final String CARBON_SEC_CONFIG = "CarbonSecConfig"; - public static final String TRUST = "Trust"; - public static final String ENCRYPTED = "encrypted"; - public static final String AUTHORIZATION = "Authorization"; - public static final String KERBEROS = "Kerberos"; - public static final String PROPERTY_LABEL = "property"; - public static final String NAME_LABEL = "name"; - - private SecurityConstants(){} - - /** - * Contains the Keystore management service related constants. - */ - public static class KeyStoreMgtConstants { - - public static final String FILTER_FIELD_ALIAS = "alias"; - public static final String FILTER_OPERATION_EQUALS = "eq"; - public static final String FILTER_OPERATION_STARTS_WITH = "sw"; - public static final String FILTER_OPERATION_ENDS_WITH = "ew"; - public static final String FILTER_OPERATION_CONTAINS = "co"; - - public static final String SERVER_TRUSTSTORE_FILE = "Security.TrustStore.Location"; - - /** - * Enum for Keystore management service related errors. - */ - public enum ErrorMessage { - - /** - * Server errors. - */ - ERROR_CODE_RETRIEVE_KEYSTORE("KSS-65001", - "Unable to retrieve the keystore for tenant: %s."), - ERROR_CODE_RETRIEVE_KEYSTORE_INFORMATION("KSS-65002", - "Unable to retrieve keystore information for keystore: %s"), - ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE("KSS-65003", - "Unable to retrieve client truststore for tenant: %s"), - ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE_ALIASES("KSS-65004", - "Unable to retrieve the client truststore aliases for tenant: %s."), - ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE_CERTIFICATE("KSS-65005", - "Unable to retrieve the client truststore certificate for alias: %s."), - ERROR_CODE_ADD_CERTIFICATE("KSS-65006", - "Unable to add certificate with alias: %s"), - ERROR_CODE_DELETE_CERTIFICATE("KSS-65007", - "Unable to delete certificate with alias: %s"), - ERROR_CODE_VALIDATE_CERTIFICATE("KSS-65008", "Error occurred while validating the " + - "certificate."), - ERROR_CODE_INITIALIZE_REGISTRY("KSS-65009", - "Unable to initialize the registry for the tenant: %s."), - /** - * Client error. - */ - ERROR_CODE_CERTIFICATE_EXISTS("KSS-60001", - "Provided certificate already exists with the alias: %s"), - ERROR_CODE_ALIAS_EXISTS("KSS-60002", - "Provided alias '%s' is already available in the keystore."), - ERROR_CODE_BAD_VALUE_FOR_FILTER("KSS-60003", - "Unsupported filter: %s."), - ERROR_CODE_UNSUPPORTED_FILTER_OPERATION("KSS-60004", - "Unsupported filter operation %s."), - ERROR_CODE_EMPTY_ALIAS("KSS-60005", "Alias value can not be null."), - ERROR_CODE_INVALID_CERTIFICATE("KSS-60006", "Provided certificate is invalid."), - ERROR_CODE_CANNOT_DELETE_TENANT_CERT("KSS-60007", "Not allowed to delete the tenant certificate %s."); - - private final String code; - private final String message; - - ErrorMessage(String code, String message) { - this.code = code; - this.message = message; - } - - public String getCode() { - return code; - } - - public String getMessage() { - return message; - } - - @Override - public String toString() { - return code + " : " + message; - } - } - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityServiceHolder.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityServiceHolder.java deleted file mode 100644 index a5606f681c7..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/SecurityServiceHolder.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security; - -import org.apache.axis2.context.ConfigurationContext; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.service.TenantRegistryLoader; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ConfigurationContextService; - -import java.util.HashMap; -import java.util.Map; - -public class SecurityServiceHolder { - - private static RegistryService registryService; - - private static RealmService realmService; - - private static ConfigurationContextService ccService; - - private static TenantRegistryLoader tenantRegistryLoader; - - private static Map policyResourceMap = new HashMap<>(); - - private SecurityServiceHolder() { - - } - - public static RegistryService getRegistryService() { - return registryService; - } - - public static void setRegistryService(RegistryService registryService) { - SecurityServiceHolder.registryService = registryService; - } - - public static Registry getRegistry() throws Exception { - if (registryService == null) { - throw new SecurityConfigException("Registry Service is null"); - } - - return registryService.getConfigSystemRegistry(); - - } - - public static RealmService getRealmService() throws Exception { - if (realmService == null) { - throw new SecurityConfigException("The main user realm is null"); - } - return realmService; - } - - public static void setRealmService(RealmService realmService) { - SecurityServiceHolder.realmService = realmService; - } - - public static ConfigurationContext getConfigurationContext() throws Exception { - if (ccService == null) { - throw new SecurityConfigException("CC service is null"); - } - return ccService.getClientConfigContext(); - } - - public static void setConfigurationContextService(ConfigurationContextService ccService) { - SecurityServiceHolder.ccService = ccService; - } - - public static void addPolicyResource(String location, Resource resource) { - policyResourceMap.put(location, resource); - } - - public static TenantRegistryLoader getTenantRegistryLoader() { - return tenantRegistryLoader; - } - - public static void setTenantRegistryLoader(TenantRegistryLoader tenantRegistryLoader) { - SecurityServiceHolder.tenantRegistryLoader = tenantRegistryLoader; - } - - public static Map getPolicyResourceMap() { - return policyResourceMap; - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/internal/SecurityMgtServiceComponent.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/internal/SecurityMgtServiceComponent.java deleted file mode 100644 index fe1cea36fca..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/internal/SecurityMgtServiceComponent.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.internal; - -import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.component.annotations.Reference; -import org.osgi.service.component.annotations.ReferenceCardinality; -import org.osgi.service.component.annotations.ReferencePolicy; -import org.wso2.carbon.core.RegistryResources; -import org.wso2.carbon.identity.core.util.IdentityCoreInitializedEvent; -import org.wso2.carbon.registry.core.Collection; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.jdbc.utils.Transaction; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.service.TenantRegistryLoader; -import org.wso2.carbon.security.SecurityConstants; -import org.wso2.carbon.security.SecurityServiceHolder; -import org.wso2.carbon.security.keystore.KeyStoreManagementService; -import org.wso2.carbon.security.keystore.KeyStoreManagementServiceImpl; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ConfigurationContextService; - -@Component( - name = "security.mgt.service.component", - immediate = true -) -public class SecurityMgtServiceComponent { - private static String POX_SECURITY_MODULE = "POXSecurityModule"; - private static final Log log = LogFactory.getLog(SecurityMgtServiceComponent.class); - private static ConfigurationContextService configContextService = null; - private static RealmService realmService; - private static RegistryService registryService; - - public static ConfigurationContext getServerConfigurationContext() { - return configContextService.getServerConfigContext(); - } - - @Activate - protected void activate(ComponentContext ctxt) { - try { - BundleContext bundleCtx = ctxt.getBundleContext(); - bundleCtx.registerService(KeyStoreManagementService.class.getName(), new KeyStoreManagementServiceImpl(), - null); - try { - addKeystores(); - } catch (Exception e) { - String msg = "Error while adding key stores."; - log.error(msg, e); - throw new RuntimeException(msg, e); - } - - log.debug("Security Mgt bundle is activated"); - } catch (Throwable e) { - log.error("Failed to activate SecurityMgtServiceComponent", e); - } - } - - @Deactivate - protected void deactivate(ComponentContext ctxt) { - log.debug("Security Mgt bundle is deactivated"); - } - - @Reference( - name = "config.context.service", - service = ConfigurationContextService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "unsetConfigurationContextService" - ) - protected void setConfigurationContextService(ConfigurationContextService contextService) { - if (log.isDebugEnabled()) { - log.debug("Setting the ConfigurationContext"); - } - configContextService = contextService; - SecurityServiceHolder.setConfigurationContextService(contextService); - } - - @Reference( - name = "registry.service", - service = RegistryService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "unsetRegistryService" - ) - protected void setRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("Setting the RegistryService"); - } - this.registryService = registryService; - SecurityServiceHolder.setRegistryService(registryService); - } - - @Reference( - name = "user.realmservice.default", - service = RealmService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "unsetRealmService" - ) - protected void setRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Setting the RealmService"); - } - this.realmService = realmService; - SecurityServiceHolder.setRealmService(realmService); - } - - protected void unsetRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting the RealmService"); - } - this.realmService = null; - SecurityServiceHolder.setRealmService(null); - } - - protected void unsetConfigurationContextService(ConfigurationContextService contextService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting the ConfigurationContext"); - } - this.configContextService = null; - SecurityServiceHolder.setConfigurationContextService(contextService); - } - - protected void unsetRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting the RegistryService"); - } - this.registryService = registryService; - SecurityServiceHolder.setRegistryService(registryService); // TODO: Serious OSGi bug here. FIXME Thilina - } - - @Reference( - name = "registry.loader.default", - service = TenantRegistryLoader.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "unsetTenantRegistryLoader" - ) - protected void setTenantRegistryLoader(TenantRegistryLoader tenantRegistryLoader) { - if (log.isDebugEnabled()) { - log.debug("Tenant Registry Loader is set in the SAML SSO bundle"); - } - SecurityServiceHolder.setTenantRegistryLoader(tenantRegistryLoader); - } - - protected void unsetTenantRegistryLoader(TenantRegistryLoader tenantRegistryLoader) { - if (log.isDebugEnabled()) { - log.debug("Tenant Registry Loader is unset in the SAML SSO bundle"); - } - SecurityServiceHolder.setTenantRegistryLoader(null); - } - - @Reference( - name = "identityCoreInitializedEventService", - service = IdentityCoreInitializedEvent.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "unsetIdentityCoreInitializedEventService" - ) - protected void setIdentityCoreInitializedEventService(IdentityCoreInitializedEvent identityCoreInitializedEvent) { - /* reference IdentityCoreInitializedEvent service to guarantee that this component will wait until identity core - is started */ - } - - protected void unsetIdentityCoreInitializedEventService(IdentityCoreInitializedEvent identityCoreInitializedEvent) { - /* reference IdentityCoreInitializedEvent service to guarantee that this component will wait until identity core - is started */ - } - - public static RegistryService getRegistryService(){ - return registryService; - } - - private void addKeystores() throws RegistryException { - Registry registry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry(); - try { - boolean transactionStarted = Transaction.isStarted(); - if (!transactionStarted) { - registry.beginTransaction(); - } - if (!registry.resourceExists(SecurityConstants.KEY_STORES)) { - Collection kstores = registry.newCollection(); - registry.put(SecurityConstants.KEY_STORES, kstores); - - Resource primResource = registry.newResource(); - if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) { - registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE, - primResource); - } - } - if (!transactionStarted) { - registry.commitTransaction(); - } - } catch (Exception e) { - registry.rollbackTransaction(); - throw e; - } - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreAdmin.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreAdmin.java deleted file mode 100644 index 5c020ac9648..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreAdmin.java +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore; - -import org.apache.axiom.om.util.Base64; -import org.apache.axis2.context.MessageContext; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.core.RegistryResources; -import org.wso2.carbon.core.util.CryptoUtil; -import org.wso2.carbon.core.util.KeyStoreManager; -import org.wso2.carbon.core.util.KeyStoreUtil; -import org.wso2.carbon.identity.core.util.IdentityUtil; -import org.wso2.carbon.registry.core.Association; -import org.wso2.carbon.registry.core.Collection; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.security.SecurityConfigException; -import org.wso2.carbon.security.SecurityConstants; -import org.wso2.carbon.security.keystore.service.CertData; -import org.wso2.carbon.security.keystore.service.CertDataDetail; -import org.wso2.carbon.security.keystore.service.KeyStoreData; -import org.wso2.carbon.security.keystore.service.PaginatedCertData; -import org.wso2.carbon.security.keystore.service.PaginatedKeyStoreData; -import org.wso2.carbon.security.util.KeyStoreMgtUtil; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.Key; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.text.Format; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; - -public class KeyStoreAdmin { - - //trust store - public static final String SERVER_TRUSTSTORE_FILE = "Security.TrustStore.Location"; - public static final String SERVER_TRUSTSTORE_PASSWORD = "Security.TrustStore.Password"; - public static final String SERVER_TRUSTSTORE_TYPE = "Security.TrustStore.Type"; - - private static final Log log = LogFactory.getLog(KeyStoreAdmin.class); - private Registry registry = null; - private int tenantId; - private boolean includeCert = false; - - private static String TRUST_STORE_LOCATION; - private static String TRUST_STORE_PASSWORD; - - public KeyStoreAdmin(int tenantId, Registry registry) { - - ServerConfiguration config = ServerConfiguration.getInstance(); - TRUST_STORE_LOCATION = config.getFirstProperty("Security.TrustStore.Location"); - TRUST_STORE_PASSWORD = config.getFirstProperty("Security.TrustStore.Password"); - this.registry = registry; - this.tenantId = tenantId; - } - - public boolean isIncludeCert() { - return includeCert; - } - - public void setIncludeCert(boolean includeCert) { - this.includeCert = includeCert; - } - - /** - * Method to retrive keystore data. - * - * @param isSuperTenant - Indication whether the querying super tennat data - * @return - * @throws SecurityConfigException - */ - public KeyStoreData[] getKeyStores(boolean isSuperTenant) throws SecurityConfigException { - CarbonUtils.checkSecurity(); - KeyStoreData[] names = new KeyStoreData[0]; - try { - if (registry.resourceExists(SecurityConstants.KEY_STORES)) { - Collection collection = (Collection) registry.get(SecurityConstants.KEY_STORES); - String[] ks = collection.getChildren(); - List lst = new ArrayList<>(); - for (int i = 0; i < ks.length; i++) { - String fullname = ks[i]; - - if (RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE - .equals(fullname)) { - continue; - } - - Resource store = registry.get(ks[i]); - int lastIndex = fullname.lastIndexOf("/"); - String name = fullname.substring(lastIndex + 1); - String type = store.getProperty(SecurityConstants.PROP_TYPE); - String provider = store.getProperty(SecurityConstants.PROP_PROVIDER); - - KeyStoreData data = new KeyStoreData(); - data.setKeyStoreName(name); - data.setKeyStoreType(type); - data.setProvider(provider); - - String alias = store.getProperty(SecurityConstants.PROP_PRIVATE_KEY_ALIAS); - if (alias != null) { - data.setPrivateStore(true); - } else { - data.setPrivateStore(false); - } - - // Dump the generated public key to the file system for sub tenants - if (!isSuperTenant) { - Association[] associations = registry.getAssociations( - ks[i], SecurityConstants.ASSOCIATION_TENANT_KS_PUB_KEY); - if (associations != null && associations.length > 0) { - Resource pubKeyResource = registry.get(associations[0].getDestinationPath()); - String fileName = generatePubCertFileName(ks[i], - pubKeyResource.getProperty( - SecurityConstants.PROP_TENANT_PUB_KEY_FILE_NAME_APPENDER)); - if (MessageContext.getCurrentMessageContext() != null) { - String pubKeyFilePath = KeyStoreMgtUtil.dumpCert( - MessageContext.getCurrentMessageContext().getConfigurationContext(), - (byte[]) pubKeyResource.getContent(), fileName); - data.setPubKeyFilePath(pubKeyFilePath); - } - } - } - lst.add(data); - - } - names = new KeyStoreData[lst.size() + 1]; - Iterator ite = lst.iterator(); - int count = 0; - while (ite.hasNext()) { - names[count] = ite.next(); - count++; - } - - if (isSuperTenant) { - KeyStoreData data = new KeyStoreData(); - ServerConfiguration config = ServerConfiguration.getInstance(); - String fileName = config - .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIMARY_KEYSTORE_FILE); - String type = config - .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIMARY_KEYSTORE_TYPE); - String name = KeyStoreUtil.getKeyStoreFileName(fileName); - data.setKeyStoreName(name); - data.setKeyStoreType(type); - data.setProvider(" "); - data.setPrivateStore(true); - - names[count] = data; - } - - } - return names; - } catch (RegistryException e) { - String msg = "Error when getting keyStore data"; - log.error(msg, e); - throw new SecurityConfigException(msg, e); - } - } - - public void addKeyStoreWithFilePath(String filePath, String filename, String password, - String provider, String type, String pvtkeyPass) throws SecurityConfigException { - try { - addKeyStore(readBytesFromFile(filePath), filename, password, provider, type, pvtkeyPass); - } catch (IOException e) { - throw new SecurityConfigException("Error while loading keystore from file " + filePath, e); - } - - } - - public void addKeyStore(String fileData, String filename, String password, String provider, - String type, String pvtkeyPass) throws SecurityConfigException { - byte[] content = Base64.decode(fileData); - addKeyStore(content, filename, password, provider, type, pvtkeyPass); - } - - public void addKeyStore(byte[] content, String filename, String password, String provider, - String type, String pvtkeyPass) throws SecurityConfigException { - if (filename == null) { - throw new SecurityConfigException("Key Store name can't be null"); - } - try { - if (KeyStoreUtil.isPrimaryStore(filename)) { - throw new SecurityConfigException("Key store " + filename + " already available"); - } - if (isTrustStore(filename)) { - throw new SecurityConfigException("Key store " + filename + " already available"); - } - String path = SecurityConstants.KEY_STORES + "/" + filename; - if (registry.resourceExists(path)) { - throw new SecurityConfigException("Key store " + filename + " already available"); - } - - KeyStore keyStore = KeyStore.getInstance(type); - keyStore.load(new ByteArrayInputStream(content), password.toCharArray()); - - // check for more private keys - Enumeration enumeration = keyStore.aliases(); - String pvtKeyAlias = null; - while (enumeration.hasMoreElements()) { - String alias = (String) enumeration.nextElement(); - if (keyStore.isKeyEntry(alias)) { - pvtKeyAlias = alias; - } - } - - // just to test weather pvt key password is correct. - keyStore.getKey(pvtKeyAlias, pvtkeyPass.toCharArray()); - - CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); - - Resource resource = registry.newResource(); - resource.addProperty(SecurityConstants.PROP_PASSWORD, cryptoUtil - .encryptAndBase64Encode(password.getBytes())); - resource.addProperty(SecurityConstants.PROP_PROVIDER, provider); - resource.addProperty(SecurityConstants.PROP_TYPE, type); - - if (pvtKeyAlias != null) { - resource.addProperty(SecurityConstants.PROP_PRIVATE_KEY_ALIAS, pvtKeyAlias); - resource.addProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS, cryptoUtil - .encryptAndBase64Encode(pvtkeyPass.getBytes())); - } - - resource.setContent(content); - registry.put(path, resource); - } catch (SecurityConfigException e) { - throw e; - } catch (Exception e) { - String msg = "Error when adding a keyStore"; - log.error(msg, e); - throw new SecurityConfigException(msg, e); - } - } - - public void addTrustStore(String fileData, String filename, String password, String provider, - String type) throws SecurityConfigException { - byte[] content = Base64.decode(fileData); - addTrustStore(content, filename, password, provider, type); - } - - public void addTrustStore(byte[] content, String filename, String password, String provider, String type) throws SecurityConfigException { - if (filename == null) { - throw new SecurityConfigException("Key Store name can't be null"); - } - try { - if (KeyStoreUtil.isPrimaryStore(filename)) { - throw new SecurityConfigException("Key store " + filename + " already available"); - } - - String path = SecurityConstants.KEY_STORES + "/" + filename; - if (registry.resourceExists(path)) { - throw new SecurityConfigException("Key store " + filename + " already available"); - } - - KeyStore keyStore = KeyStore.getInstance(type); - keyStore.load(new ByteArrayInputStream(content), password.toCharArray()); - CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); - Resource resource = registry.newResource(); - resource.addProperty(SecurityConstants.PROP_PASSWORD, cryptoUtil - .encryptAndBase64Encode(password.getBytes())); - resource.addProperty(SecurityConstants.PROP_PROVIDER, provider); - resource.addProperty(SecurityConstants.PROP_TYPE, type); - resource.setContent(content); - registry.put(path, resource); - } catch (SecurityConfigException e) { - throw e; - } catch (Exception e) { - String msg = "Error when adding a trustStore"; - log.error(msg, e); - throw new SecurityConfigException(msg, e); - } - } - - public void deleteStore(String keyStoreName) throws SecurityConfigException { - try { - - if (StringUtils.isBlank(keyStoreName)) { - throw new SecurityConfigException("Key Store name can't be null"); - } - - if (KeyStoreUtil.isPrimaryStore(keyStoreName)) { - throw new SecurityConfigException("Not allowed to delete the primary key store : " - + keyStoreName); - } - if (isTrustStore(keyStoreName)) { - throw new SecurityConfigException("Not allowed to delete the trust store : " - + keyStoreName); - } - String path = SecurityConstants.KEY_STORES + "/" + keyStoreName; - boolean isFound = false; - Association[] assocs = registry.getAllAssociations(path); - if (assocs.length > 0) { - isFound = true; - } - - if (isFound) { - throw new SecurityConfigException("Key store : " + keyStoreName + - " is already in use and can't be deleted"); - } - registry.delete(path); - } catch (RegistryException e) { - String msg = "Error when deleting a keyStore"; - log.error(msg, e); - throw new SecurityConfigException(msg, e); - } - } - - public void importCertToStore(String fileName, String certData, String keyStoreName) - throws SecurityConfigException { - try { - if (keyStoreName == null) { - throw new SecurityConfigException("Key Store name can't be null"); - } - - KeyStore ks = getKeyStore(keyStoreName); - X509Certificate cert = extractCertificate(certData); - - if (ks.getCertificateAlias(cert) != null) { - // We already have this certificate in the key store - ignore - // adding it twice - return; - } - - ks.setCertificateEntry(fileName, cert); - - updateKeyStore(keyStoreName, ks); - - if (isTrustStore(keyStoreName)) { - System.setProperty(IdentityUtil.PROP_TRUST_STORE_UPDATE_REQUIRED, "true"); - } - - } catch (SecurityConfigException e) { - throw e; - } catch (Exception e) { - String msg = "Error when importing cert to the keyStore"; - log.error(msg, e); - throw new SecurityConfigException(msg, e); - } - - } - - public String importCertToStore(String certData, String keyStoreName) - throws SecurityConfigException { - String alias = null; - - try { - if (keyStoreName == null) { - throw new SecurityConfigException("Key Store name can't be null"); - } - - KeyStore ks = getKeyStore(keyStoreName); - X509Certificate cert = extractCertificate(certData); - - if (ks.getCertificateAlias(cert) != null) { - // We already have this certificate in the key store - ignore - // adding it twice - return null; - } - alias = cert.getSubjectDN().getName(); - ks.setCertificateEntry(alias, cert); - - updateKeyStore(keyStoreName, ks); - - if (isTrustStore(keyStoreName)) { - System.setProperty(IdentityUtil.PROP_TRUST_STORE_UPDATE_REQUIRED, "true"); - } - - return alias; - - } catch (SecurityConfigException e) { - throw e; - } catch (Exception e) { - String msg = "Error when importing cert to keyStore"; - log.error(msg, e); - throw new SecurityConfigException(msg); - } - } - - public void removeCertFromStore(String alias, String keyStoreName) - throws SecurityConfigException { - try { - if (keyStoreName == null) { - throw new SecurityConfigException("Key Store name can't be null"); - } - - KeyStore ks = getKeyStore(keyStoreName); - - if (ks.getCertificate(alias) == null) { - return; - } - - ks.deleteEntry(alias); - updateKeyStore(keyStoreName, ks); - - if (isTrustStore(keyStoreName)) { - System.setProperty(IdentityUtil.PROP_TRUST_STORE_UPDATE_REQUIRED, Boolean.TRUE.toString()); - } - } catch (SecurityConfigException e) { - throw e; - } catch (Exception e) { - String msg = "Error when removing cert from store"; - log.error(msg, e); - throw new SecurityConfigException(msg); - } - } - - public String[] getStoreEntries(String keyStoreName) throws SecurityConfigException { - String[] names; - try { - if (keyStoreName == null) { - throw new Exception("keystore name cannot be null"); - } - - //KeyStoreManager keyMan = KeyStoreManager.getInstance(tenantId); - KeyStore ks = getKeyStore(keyStoreName); - - Enumeration enm = ks.aliases(); - List lst = new ArrayList<>(); - while (enm.hasMoreElements()) { - lst.add(enm.nextElement()); - } - - names = lst.toArray(new String[lst.size()]); - } catch (SecurityConfigException e) { - throw e; - } catch (Exception e) { - String msg = "Error when getting store entries"; - log.error(msg, e); - throw new SecurityConfigException(msg); - } - - return names; - } - - /** - * This method will list 1. Certificate aliases 2. Private key alise 3. Private key value to a - * given keystore. - * - * @param keyStoreName The name of the keystore - * @return Instance of KeyStoreData - * @throws SecurityConfigException will be thrown - */ - public KeyStoreData getKeystoreInfo(String keyStoreName) throws SecurityConfigException { - try { - - if (keyStoreName == null) { - throw new Exception("keystore name cannot be null"); - } - - KeyStore keyStore; - String keyStoreType; - String privateKeyPassword = null; - if (KeyStoreUtil.isPrimaryStore(keyStoreName)) { - KeyStoreManager keyMan = KeyStoreManager.getInstance(tenantId); - keyStore = keyMan.getPrimaryKeyStore(); - ServerConfiguration serverConfig = ServerConfiguration.getInstance(); - keyStoreType = serverConfig - .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIMARY_KEYSTORE_TYPE); - privateKeyPassword = serverConfig - .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIVATE_KEY_PASSWORD); - } else if (isTrustStore(keyStoreName)) { - keyStore = getTrustStore(); - ServerConfiguration serverConfig = ServerConfiguration.getInstance(); - keyStoreType = serverConfig.getFirstProperty(SERVER_TRUSTSTORE_TYPE); - privateKeyPassword = serverConfig.getFirstProperty(SERVER_TRUSTSTORE_PASSWORD); - } else { - String path = SecurityConstants.KEY_STORES + "/" + keyStoreName; - if (!registry.resourceExists(path)) { - throw new SecurityConfigException("Key Store not found"); - } - Resource resource = registry.get(path); - keyStore = getKeyStore(keyStoreName); - keyStoreType = resource.getProperty(SecurityConstants.PROP_TYPE); - - String encpass = resource.getProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS); - if (encpass != null) { - CryptoUtil util = CryptoUtil.getDefaultCryptoUtil(); - privateKeyPassword = new String(util.base64DecodeAndDecrypt(encpass)); - } - } - // Fill the information about the certificates - Enumeration aliases = keyStore.aliases(); - List certDataList = new ArrayList<>(); - 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, privateKeyPassword - .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); - } - - } - - public Key getPrivateKey(String alias, boolean isSuperTenant) throws SecurityConfigException { - KeyStoreData[] keystores = getKeyStores(isSuperTenant); - KeyStore keyStore = null; - String privateKeyPassowrd = null; - - try { - - for (int i = 0; i < keystores.length; i++) { - if (KeyStoreUtil.isPrimaryStore(keystores[i].getKeyStoreName())) { - KeyStoreManager keyMan = KeyStoreManager.getInstance(tenantId); - keyStore = keyMan.getPrimaryKeyStore(); - ServerConfiguration serverConfig = ServerConfiguration.getInstance(); - privateKeyPassowrd = serverConfig - .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIVATE_KEY_PASSWORD); - return keyStore.getKey(alias, privateKeyPassowrd.toCharArray()); - } - } - } 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; - } - - private CertData fillCertData(X509Certificate cert, String alise, Format formatter) - throws CertificateEncodingException { - CertData certData = null; - - if (includeCert) { - certData = new CertDataDetail(); - } else { - certData = new CertData(); - } - certData.setAlias(alise); - certData.setSubjectDN(cert.getSubjectDN().getName()); - certData.setIssuerDN(cert.getIssuerDN().getName()); - certData.setSerialNumber(cert.getSerialNumber()); - certData.setVersion(cert.getVersion()); - certData.setNotAfter(formatter.format(cert.getNotAfter())); - certData.setNotBefore(formatter.format(cert.getNotBefore())); - certData.setPublicKey(Base64.encode(cert.getPublicKey().getEncoded())); - - if (includeCert) { - ((CertDataDetail) certData).setCertificate(cert); - } - - return certData; - } - - private byte[] readBytesFromFile(String filePath) throws IOException { - InputStream inputStream = null; - File file = new File(filePath); - long length; - byte[] bytes; - int offset = 0; - int numRead = 0; - - try { - inputStream = new FileInputStream(file); - length = file.length(); - bytes = new byte[(int) length]; - - while (offset < bytes.length - && (numRead = inputStream.read(bytes, offset, bytes.length - offset)) >= 0) { - offset += numRead; - } - } finally { - if (inputStream != null) { - inputStream.close(); - } - } - - return bytes; - } - - /** - * This method is used to generate the file name of the pub. cert of a tenant - * - * @param ksLocation keystore location in the registry - * @param uuid UUID appender - * @return file name of the pub. cert - */ - private String generatePubCertFileName(String ksLocation, String uuid) { - String tenantName = ksLocation.substring(ksLocation.lastIndexOf("/")); - if (tenantName.endsWith(".jks")) { - tenantName = tenantName.replace(".jks", ""); - } - return tenantName + "-" + uuid + ".cert"; - } - - /** - * This method is used internally to do the pagination purposes. - * - * @param pageNumber page Number - * @param certDataSet set of keyStoreData - * @return PaginatedPolicySetDTO object containing the number of pages and the set of policies - * that reside in the given page. - */ - private PaginatedCertData doPaging(int pageNumber, CertData[] certDataSet) { - - PaginatedCertData paginatedCertData = new PaginatedCertData(); - if (certDataSet.length == 0) { - paginatedCertData.setCertDataSet(new CertData[0]); - return paginatedCertData; - } - int itemsPerPageInt = SecurityConstants.ITEMS_PER_PAGE; - int numberOfPages = (int) Math.ceil((double) certDataSet.length / itemsPerPageInt); - if (pageNumber > numberOfPages - 1) { - pageNumber = numberOfPages - 1; - } - int startIndex = pageNumber * itemsPerPageInt; - int endIndex = certDataSet.length; - if (numberOfPages > SecurityConstants.CACHING_PAGE_SIZE) { - endIndex = (pageNumber + SecurityConstants.CACHING_PAGE_SIZE) * itemsPerPageInt; - } - CertData[] returnedCertDataSet = new CertData[endIndex]; - - for (int i = startIndex, j = 0; i < endIndex && i < certDataSet.length; i++, j++) { - returnedCertDataSet[j] = certDataSet[i]; - } - - paginatedCertData.setCertDataSet(returnedCertDataSet); - paginatedCertData.setNumberOfPages(numberOfPages); - - return paginatedCertData; - } - - /** - * This method is used internally for the filtering purposes. - * - * @param filter Filter string. - * @param certDataSet Certificate or key array. - * @return Cert Data array after filtering. - */ - private static CertData[] doFilter(String filter, CertData[] certDataSet) { - - if (certDataSet != null && certDataSet.length != 0) { - String regPattern = filter.replace("*", ".*"); - List certDataList = new ArrayList(); - - for (CertData cert : certDataSet) { - if (cert != null && cert.getAlias().toLowerCase().matches(regPattern.toLowerCase())) { - certDataList.add(cert); - } - } - - return (CertData[]) certDataList.toArray(new CertData[0]); - } else { - return new CertData[0]; - } - } - - /** - * Gets the keystore info by keystore name with its certificates and key certificates. - * - * @param keyStoreName The name of the keystore - * @param pageNumber page number - * @return Instance of KeyStoreData - * @throws SecurityConfigException will be thrown - */ - public PaginatedKeyStoreData getPaginatedKeystoreInfo(String keyStoreName, int pageNumber) - throws SecurityConfigException { - - if (StringUtils.isEmpty(keyStoreName)) { - throw new SecurityConfigException("Keystore name cannot be empty or null."); - } - - try { - // Get keystore. - KeyStore keyStore = getKeyStore(tenantId, keyStoreName); - // Get keystore type. - String keyStoreType = getKeyStoreType(keyStoreName); - - // Extract certificates from aliases as list. - List certDataList = getCertificates(keyStore); - List keyCertDataList = getKeyCertificates(keyStore); - - // Create a certificate array. - CertData[] certs = certDataList.toArray(new CertData[certDataList.size()]); - // Get paginated certificates. - PaginatedCertData paginatedCerts = doPaging(pageNumber, certs); - - // Create a key certificate array. - CertData[] keyCerts = keyCertDataList.toArray(new CertData[keyCertDataList.size()]); - // Get paginated key certificates. - PaginatedCertData paginatedKeyCerts = doPaging(pageNumber, keyCerts); - - // Fill information about the keystore to PaginatedKeyStoreData. - PaginatedKeyStoreData keyStoreData = fillPaginatedKeyStoreData(keyStoreName, keyStoreType, - paginatedCerts, paginatedKeyCerts); - - return keyStoreData; - } catch (Exception e) { - throw new SecurityConfigException(e.getMessage()); - } - - } - - /** - * Gets the keystore info by keystore name and filters its certificates and key certificates - * by applying the filter for certificate aliases. - * - * @param keyStoreName The name of the keystore. - * @param pageNumber Page number. - * @param filter Filter for certificate alias. - * @return Instance of KeyStoreData. - * @throws SecurityConfigException will be thrown. - */ - public PaginatedKeyStoreData getFilteredPaginatedKeyStoreInfo(String keyStoreName, int pageNumber, - String filter) throws SecurityConfigException { - - if (StringUtils.isEmpty(keyStoreName)) { - throw new SecurityConfigException("Keystore name cannot be empty or null."); - } - - try { - // Get keystore. - KeyStore keyStore = getKeyStore(tenantId, keyStoreName); - // Get keystore type. - String keyStoreType = getKeyStoreType(keyStoreName); - - // Extract certificates from aliases as list. - List certDataList = getCertificates(keyStore); - List keyCertDataList = getKeyCertificates(keyStore); - // Filter and paginate certs and keyCerts. - PaginatedCertData paginatedCerts = filterAndPaginateCerts(certDataList, filter, pageNumber); - PaginatedCertData paginatedKeyCerts = filterAndPaginateCerts(keyCertDataList, filter, pageNumber); - // Fill information about the keystore to PaginatedKeyStoreData. - PaginatedKeyStoreData keyStoreData = fillPaginatedKeyStoreData(keyStoreName, keyStoreType, - paginatedCerts, paginatedKeyCerts); - - return keyStoreData; - } catch (Exception e) { - throw new SecurityConfigException(e.getMessage()); - } - } - - /** - * @param tenantId Tenant Id. - * @param keyStoreName Keystore Name. - * @return - * @throws Exception - */ - private KeyStore getKeyStore(int tenantId, String keyStoreName) throws Exception { - - KeyStore keyStore; - if (KeyStoreUtil.isPrimaryStore(keyStoreName)) { - KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(tenantId); - keyStore = keyStoreManager.getPrimaryKeyStore(); - } else if (isTrustStore(keyStoreName)) { - keyStore = getTrustStore(); - } else { - keyStore = getKeyStore(keyStoreName); - } - return keyStore; - } - - /** - * Get keystore type. - * - * @param keyStoreName Keystore name. - * @return - * @throws SecurityConfigException - * @throws RegistryException - */ - private String getKeyStoreType(String keyStoreName) throws SecurityConfigException, RegistryException { - - String keyStoreType; - if (KeyStoreUtil.isPrimaryStore(keyStoreName)) { - ServerConfiguration serverConfig = ServerConfiguration.getInstance(); - keyStoreType = serverConfig - .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIMARY_KEYSTORE_TYPE); - } else if (isTrustStore(keyStoreName)) { - ServerConfiguration serverConfig = ServerConfiguration.getInstance(); - keyStoreType = serverConfig.getFirstProperty(SERVER_TRUSTSTORE_TYPE); - } else { - String path = SecurityConstants.KEY_STORES + "/" + keyStoreName; - if (!registry.resourceExists(path)) { - throw new SecurityConfigException("Keystore " + keyStoreName + " not found at " + path); - } - Resource resource = registry.get(path); - keyStoreType = resource.getProperty(SecurityConstants.PROP_TYPE); - } - return keyStoreType; - } - - /** - * Fill PaginatedKeyStoreData with keystore details. - * - * @param keyStoreName Name of the keystore. - * @param keyStoreType Type of the keystore. - * @param certs Paginated certificates. - * @param keyCerts Paginated key certificates. - * @return Paginated KeyStore Data. - */ - private PaginatedKeyStoreData fillPaginatedKeyStoreData(String keyStoreName, String keyStoreType, - PaginatedCertData certs, PaginatedCertData keyCerts) { - - // Create a KeyStoreData bean, set the name, type and fill in the cert information. - PaginatedKeyStoreData keyStoreData = new PaginatedKeyStoreData(); - keyStoreData.setKeyStoreName(keyStoreName); - keyStoreData.setKeyStoreType(keyStoreType); - keyStoreData.setPaginatedCertData(certs); - keyStoreData.setPaginatedKeyData(keyCerts); - return keyStoreData; - } - - /** - * Get certificates related to alias from the keystore. - * - * @param keyStore Keystore - * @return List of certificate data. - * @throws KeyStoreException - * @throws CertificateEncodingException - */ - private List getCertificates(KeyStore keyStore) - throws KeyStoreException, CertificateEncodingException { - - Enumeration aliases = keyStore.aliases(); - // Create lists for cert and key lists. - List certDataList = new ArrayList<>(); - Format formatter = new SimpleDateFormat("dd/MM/yyyy"); - - while (aliases.hasMoreElements()) { - String alias = aliases.nextElement(); - X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias); - if (keyStore.isCertificateEntry(alias)) { - certDataList.add(fillCertData(cert, alias, formatter)); - } - } - return certDataList; - } - - /** - * Get key certificates related to alias from the keystore. - * - * @param keyStore Keystore - * @return List of certificate data. - * @throws KeyStoreException - * @throws CertificateEncodingException - */ - private List getKeyCertificates(KeyStore keyStore) - throws KeyStoreException, CertificateEncodingException { - - Enumeration aliases = keyStore.aliases(); - // Create lists for cert and key lists. - List certDataList = new ArrayList<>(); - Format formatter = new SimpleDateFormat("dd/MM/yyyy"); - - while (aliases.hasMoreElements()) { - String alias = aliases.nextElement(); - X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias); - if (keyStore.isKeyEntry(alias)) { - certDataList.add(fillCertData(cert, alias, formatter)); - } - } - return certDataList; - } - - /** - * Filter and paginate certificate list. - * - * @param certDataList Certificate list. - * @param filterString Filter text. - * @param pageNumber Page number. - * @return Paginated and Filtered Certificate Data. - */ - private PaginatedCertData filterAndPaginateCerts(List certDataList, String filterString, int pageNumber) { - - PaginatedCertData paginatedCerts; - CertData[] certs = certDataList.toArray(new CertData[0]); - certs = (doFilter(filterString, certs)); - paginatedCerts = doPaging(pageNumber, certs); - return paginatedCerts; - } - - /** - * Load the default trust store (allowed only for super tenant). - * - * @return trust store object - * @throws SecurityConfigException if retrieving the truststore fails. - */ - public KeyStore getTrustStore() throws SecurityConfigException { - - //Allow only the super tenant to access the default trust store. - if (tenantId != MultitenantConstants.SUPER_TENANT_ID) { - throw new SecurityConfigException("Permission denied for accessing trust store"); - } - - KeyStore trustStore; - ServerConfiguration serverConfiguration = ServerConfiguration.getInstance(); - String file = new File(serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_FILE)).getAbsolutePath(); - - KeyStore store; - try { - store = KeyStore.getInstance(serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_TYPE)); - } catch (KeyStoreException e) { - throw new SecurityConfigException("Error occurred while loading keystore.", e); - } - - String password = serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_PASSWORD); - - try (FileInputStream in = new FileInputStream(file)) { - store.load(in, password.toCharArray()); - trustStore = store; - } catch (CertificateException | NoSuchAlgorithmException | IOException e) { - throw new SecurityConfigException("Error occurred while loading trust store", e); - } - return trustStore; - } - - /** - * Check if the supplied id is the system configured trust store - * - * @param id id (file name) of the keystore - * @return boolean true if supplied id is the configured trust store - */ - private boolean isTrustStore(String id) { - - ServerConfiguration serverConfiguration = ServerConfiguration.getInstance(); - String fileName = serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_FILE); - int index = fileName.lastIndexOf('/'); - if (index != -1) { - String name = fileName.substring(index + 1); - if (name.equals(id)) { - return true; - } - } else { - index = fileName.lastIndexOf(File.separatorChar); - String name; - if (index != -1) { - name = fileName.substring(fileName.lastIndexOf(File.separatorChar)); - } else { - name = fileName; - } - - if (name.equals(id)) { - return true; - } - } - return false; - } - - /** - * Retrieves the {@link KeyStore} object of the given keystore name. - * - * @param keyStoreName name of the keystore. - * @return {@link KeyStore} object. - * @throws Exception if retrieving the keystore fails. - */ - public KeyStore getKeyStore(String keyStoreName) throws Exception { - - if (isTrustStore(keyStoreName)) { - return getTrustStore(); - } else { - KeyStoreManager keyMan = KeyStoreManager.getInstance(tenantId); - return keyMan.getKeyStore(keyStoreName); - } - } - - private void updateKeyStore(String name, KeyStore keyStore) throws Exception { - - FileOutputStream resource1; - String outputStream1; - String path; - if (isTrustStore(name)) { - path = (new File(TRUST_STORE_LOCATION)).getAbsolutePath(); - resource1 = null; - - try { - resource1 = new FileOutputStream(path); - outputStream1 = TRUST_STORE_PASSWORD; - keyStore.store(resource1, outputStream1.toCharArray()); - } finally { - if (resource1 != null) { - resource1.close(); - } - } - } else { - KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(tenantId); - keyStoreManager.updateKeyStore(name, keyStore); - } - } - - /** - * Extract the encoded certificate into {@link X509Certificate}. - * - * @param certData encoded certificate. - * @return {@link X509Certificate} object. - * @throws SecurityConfigException if extracting the certificate fails. - */ - public X509Certificate extractCertificate(String certData) throws SecurityConfigException { - - byte[] bytes = Base64.decode(certData); - X509Certificate cert; - try { - CertificateFactory factory = CertificateFactory.getInstance("X.509"); - cert = (X509Certificate) factory - .generateCertificate(new ByteArrayInputStream(bytes)); - } catch (CertificateException e) { - if (log.isDebugEnabled()) { - log.debug(e.getMessage(), e); - } - throw new SecurityConfigException("Invalid format of the provided certificate file"); - } - return cert; - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementClientException.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementClientException.java deleted file mode 100644 index 85b1c0a5cd4..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementClientException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.keystore; - -/** - * Handles the Keystore Management client level errors. - */ -public class KeyStoreManagementClientException extends KeyStoreManagementException { - - public KeyStoreManagementClientException(String errorCode, String message) { - super(errorCode, message); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementException.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementException.java deleted file mode 100644 index 90776f1e7be..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.keystore; - -import org.wso2.carbon.identity.base.IdentityException; - -/** - * Handles the Keystore Management errors. - */ -public class KeyStoreManagementException extends IdentityException { - - public KeyStoreManagementException(String message) { - super(message); - } - - public KeyStoreManagementException(String errorCode, String message) { - super(errorCode, message); - } - - public KeyStoreManagementException(String message, Throwable cause) { - super(message, cause); - } - - public KeyStoreManagementException(String errorCode, String message, Throwable cause) { - super(errorCode, message, cause); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementServerException.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementServerException.java deleted file mode 100644 index 7ed6c8d46a5..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementServerException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.keystore; - -/** - * Handles the Keystore Management server level errors. - */ -public class KeyStoreManagementServerException extends KeyStoreManagementException { - - public KeyStoreManagementServerException(String errorCode, String message) { - super(errorCode, message); - } - - public KeyStoreManagementServerException(String errorCode, String message, Throwable cause) { - super(errorCode, message, cause); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementService.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementService.java deleted file mode 100644 index 9cb0fa5b509..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementService.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.keystore; - -import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Map; - -/** - * This service contains the methods to manage certificates of the keystore and client truststore. - */ -public interface KeyStoreManagementService { - - /** - * Retrieves the list of certificate aliases from the keystore. - * - * @param tenantDomain tenant domain of the keystore. - * @param filter used to filter the result. Supports sw, ew, eq & co. eg:filter=alias+sw+wso2. - * @return the {@link List} of alias. - * @throws KeyStoreManagementException when retrieving the certificate aliases failed. - */ - List getKeyStoreCertificateAliases(String tenantDomain, String filter) throws KeyStoreManagementException; - - /** - * Retrieves the public certificate from the keystore. - * - * @param tenantDomain tenant domain of the keystore. - * @return a {@link Map} with public key alias and {@link X509Certificate}. - * @throws KeyStoreManagementException when retrieving the public certificate. - */ - Map getPublicCertificate(String tenantDomain) throws KeyStoreManagementException; - - /** - * Retrieves the certificate of the given alias from the keystore. - * - * @param tenantDomain tenant domain of the keystore. - * @param alias of the certificate. - * @return the {@link X509Certificate} - * @throws KeyStoreManagementException when retrieving the certificate failed. - */ - X509Certificate getKeyStoreCertificate(String tenantDomain, String alias) throws KeyStoreManagementException; - - /** - * Retrieves the list of certificate aliases from the client truststore. - * - * @param tenantDomain tenant domain of the keystore. - * @param filter used to filter the result. Supports sw, ew, eq & co. eg:filter=alias+sw+wso2. - * @return the {@link List} of alias - * @throws KeyStoreManagementException when retrieving the certificate aliases failed. - */ - List getClientCertificateAliases(String tenantDomain, String filter) throws KeyStoreManagementException; - - /** - * Retrieves the certificate of the given alias from the client truststore. - * - * @param tenantDomain tenant domain of the keystore. - * @param alias of the certificate. - * @return the {@link X509Certificate} - * @throws KeyStoreManagementException when retrieving the certificate failed. - */ - X509Certificate getClientCertificate(String tenantDomain, String alias) throws KeyStoreManagementException; - - /** - * Imports the certificate to the keystore. - * - * @param tenantDomain tenant domain of the keystore. - * @param alias of the certificate. - * @param certificate the certificate to be imported. - * @throws KeyStoreManagementException when importing the certificate failed. - */ - void addCertificate(String tenantDomain, String alias, String certificate) throws KeyStoreManagementException; - - /** - * Deletes the certificate from the keystore. - * - * @param tenantDomain tenant domain of the keystore. - * @param alias of the certificate. - * @throws KeyStoreManagementException when importing the certificate failed. - */ - void deleteCertificate(String tenantDomain, String alias) throws KeyStoreManagementException; -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementServiceImpl.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementServiceImpl.java deleted file mode 100644 index dd208844f5c..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/KeyStoreManagementServiceImpl.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.keystore; - -import org.apache.commons.lang.StringUtils; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.RegistryType; -import org.wso2.carbon.core.util.KeyStoreUtil; -import org.wso2.carbon.identity.base.IdentityException; -import org.wso2.carbon.identity.core.util.IdentityTenantUtil; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.security.SecurityConfigException; -import org.wso2.carbon.security.SecurityConstants; -import org.wso2.carbon.security.keystore.service.CertData; -import org.wso2.carbon.security.keystore.service.CertDataDetail; -import org.wso2.carbon.security.keystore.service.KeyStoreData; - -import java.nio.file.Paths; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_ADD_CERTIFICATE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_ALIAS_EXISTS; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_BAD_VALUE_FOR_FILTER; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_CANNOT_DELETE_TENANT_CERT; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_CERTIFICATE_EXISTS; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_DELETE_CERTIFICATE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_INITIALIZE_REGISTRY; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_EMPTY_ALIAS; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_INVALID_CERTIFICATE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE_CERTIFICATE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_RETRIEVE_KEYSTORE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_RETRIEVE_KEYSTORE_INFORMATION; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_UNSUPPORTED_FILTER_OPERATION; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.ErrorMessage.ERROR_CODE_VALIDATE_CERTIFICATE; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.FILTER_FIELD_ALIAS; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.FILTER_OPERATION_CONTAINS; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.FILTER_OPERATION_ENDS_WITH; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.FILTER_OPERATION_EQUALS; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.FILTER_OPERATION_STARTS_WITH; -import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.SERVER_TRUSTSTORE_FILE; - -/** - * This class is used to manage the keystore certificates. - */ -public class KeyStoreManagementServiceImpl implements KeyStoreManagementService { - - @Override - public List getKeyStoreCertificateAliases(String tenantDomain, String filter) - throws KeyStoreManagementException { - - KeyStoreData keyStoreInfo = getKeystoreData(tenantDomain, getKeyStoreName(tenantDomain)); - return filterAlias(getAliasList(keyStoreInfo), filter); - } - - @Override - public Map getPublicCertificate(String tenantDomain) throws KeyStoreManagementException { - - Map certData = new HashMap<>(); - KeyStoreData keyStoreInfo = getKeystoreData(tenantDomain, getKeyStoreName(tenantDomain)); - CertData key = keyStoreInfo.getKey(); - certData.put(key.getAlias(), ((CertDataDetail) key).getCertificate()); - return certData; - } - - @Override - public X509Certificate getKeyStoreCertificate(String tenantDomain, String alias) - throws KeyStoreManagementException { - - if (StringUtils.isEmpty(alias)) { - throw handleClientException(ERROR_CODE_EMPTY_ALIAS, null); - } - - KeyStoreData keyStoreInfo = getKeystoreData(tenantDomain, getKeyStoreName(tenantDomain)); - CertData key = keyStoreInfo.getKey(); - if (key != null && StringUtils.equals(key.getAlias(), alias)) { - return ((CertDataDetail) key).getCertificate(); - } - - CertData[] certDataArray = keyStoreInfo.getCerts(); - for (CertData certData : certDataArray) { - String aliasFromKeyStore = certData.getAlias(); - if (StringUtils.equals(aliasFromKeyStore, alias)) { - return ((CertDataDetail) certData).getCertificate(); - } - } - return null; - } - - @Override - public List getClientCertificateAliases(String tenantDomain, String filter) - throws KeyStoreManagementException { - - KeyStoreData truststoreInfo = getKeystoreData(tenantDomain, getTrustStoreName()); - return filterAlias(getAliasList(truststoreInfo), filter); - } - - @Override - public X509Certificate getClientCertificate(String tenantDomain, String alias) throws KeyStoreManagementException { - - if (StringUtils.isEmpty(alias)) { - throw handleClientException(ERROR_CODE_EMPTY_ALIAS, null); - } - - KeyStore trustStore = null; - try { - trustStore = getKeyStoreAdmin(tenantDomain).getTrustStore(); - } catch (SecurityConfigException e) { - throw handleServerException(ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE, tenantDomain, e); - } - - if (trustStore != null) { - try { - if (trustStore.containsAlias(alias)) { - return (X509Certificate) trustStore.getCertificate(alias); - } - } catch (KeyStoreException e) { - throw handleServerException(ERROR_CODE_RETRIEVE_CLIENT_TRUSTSTORE_CERTIFICATE, alias, e); - } - } - return null; - } - - @Override - public void addCertificate(String tenantDomain, String alias, String certificate) - throws KeyStoreManagementException { - - KeyStoreAdmin keyStoreAdmin = getKeyStoreAdmin(tenantDomain); - String keyStoreName = getKeyStoreName(tenantDomain); - X509Certificate cert; - try { - cert = keyStoreAdmin.extractCertificate(certificate); - } catch (SecurityConfigException e) { - throw handleClientException(ERROR_CODE_INVALID_CERTIFICATE, alias); - } - KeyStore keyStore; - String certAlias; - boolean isAliasExists; - try { - keyStore = keyStoreAdmin.getKeyStore(keyStoreName); - isAliasExists = keyStore.containsAlias(alias); - certAlias = keyStore.getCertificateAlias(cert); - } catch (Exception e) { - throw handleServerException(ERROR_CODE_VALIDATE_CERTIFICATE, null, e); - } - if (isAliasExists) { - throw handleClientException(ERROR_CODE_ALIAS_EXISTS, alias); - } - if (certAlias != null) { - throw handleClientException(ERROR_CODE_CERTIFICATE_EXISTS, certAlias); - } - try { - keyStoreAdmin.importCertToStore(alias, certificate, keyStoreName); - } catch (SecurityConfigException e) { - throw handleServerException(ERROR_CODE_ADD_CERTIFICATE, alias, e); - } - } - - @Override - public void deleteCertificate(String tenantDomain, String alias) throws KeyStoreManagementException { - - try { - Map publicCertificate = getPublicCertificate(tenantDomain); - if (publicCertificate.keySet().contains(alias)) { - throw handleClientException(ERROR_CODE_CANNOT_DELETE_TENANT_CERT, alias); - } - getKeyStoreAdmin(tenantDomain).removeCertFromStore(alias, getKeyStoreName(tenantDomain)); - } catch (SecurityConfigException e) { - throw handleServerException(ERROR_CODE_DELETE_CERTIFICATE, alias, e); - } - } - - private String getKeyStoreName(String tenantDomain) throws KeyStoreManagementException { - - KeyStoreData[] keyStoreDataArray = new KeyStoreData[0]; - try { - int tenantId = IdentityTenantUtil.getTenantId(tenantDomain); - IdentityTenantUtil.initializeRegistry(tenantId); - keyStoreDataArray = getKeyStoreAdmin(tenantDomain).getKeyStores(isSuperTenant(tenantDomain)); - } catch (SecurityConfigException e) { - throw handleServerException(ERROR_CODE_RETRIEVE_KEYSTORE, tenantDomain, e); - } catch (IdentityException e) { - throw handleServerException(ERROR_CODE_INITIALIZE_REGISTRY, tenantDomain, e); - } - - for (KeyStoreData keyStoreData : keyStoreDataArray) { - if (keyStoreData == null) { - break; - } - String keyStoreName = keyStoreData.getKeyStoreName(); - if (isSuperTenant(tenantDomain)) { - if (KeyStoreUtil.isPrimaryStore(keyStoreName)) { - return keyStoreName; - } - } else { - String tenantKeyStoreName = tenantDomain.trim().replace(".", "-") + ".jks"; - if (StringUtils.equals(keyStoreName, tenantKeyStoreName)) { - return keyStoreName; - } - } - } - throw handleServerException(ERROR_CODE_RETRIEVE_KEYSTORE, tenantDomain); - } - - private KeyStoreData getKeystoreData(String tenantDomain, String keyStoreName) throws KeyStoreManagementException { - - KeyStoreAdmin keyStoreAdmin = getKeyStoreAdmin(tenantDomain); - KeyStoreData keyStoreData = null; - keyStoreAdmin.setIncludeCert(true); - try { - keyStoreData = keyStoreAdmin.getKeystoreInfo(keyStoreName); - } catch (SecurityConfigException e) { - throw handleServerException(ERROR_CODE_RETRIEVE_KEYSTORE_INFORMATION, keyStoreName, e); - } - return keyStoreData; - } - - private List getAliasList(KeyStoreData keyStoreData) { - - List aliasList = new ArrayList<>(); - CertData key = keyStoreData.getKey(); - if (key != null && key.getAlias() != null) { - aliasList.add(key.getAlias()); - } - - CertData[] certDataArray = keyStoreData.getCerts(); - for (CertData certData : certDataArray) { - String alias = certData.getAlias(); - if (alias != null) { - aliasList.add(alias); - } - } - return aliasList; - } - - private List filterAlias(List aliases, String filter) throws KeyStoreManagementException { - - if (filter != null) { - filter = filter.replace(" ", "+"); - String[] extractedFilter = filter.split("[+]"); - if (extractedFilter.length == 3) { - if (StringUtils.equals(extractedFilter[0], FILTER_FIELD_ALIAS)) { - String operation = extractedFilter[1]; - String value = extractedFilter[2]; - if (StringUtils.equals(operation, FILTER_OPERATION_EQUALS)) { - aliases = aliases.stream().filter(alias -> alias.matches(value)) - .collect(Collectors.toList()); - } else if (StringUtils.equals(operation, FILTER_OPERATION_STARTS_WITH)) { - aliases = aliases.stream().filter(alias -> alias.startsWith(value)) - .collect(Collectors.toList()); - } else if (StringUtils.equals(operation, FILTER_OPERATION_ENDS_WITH)) { - aliases = aliases.stream().filter(alias -> alias.endsWith(value)) - .collect(Collectors.toList()); - } else if (StringUtils.equals(operation, FILTER_OPERATION_CONTAINS)) { - aliases = aliases.stream().filter(alias -> alias.contains(value)) - .collect(Collectors.toList()); - } else { - throw handleClientException(ERROR_CODE_UNSUPPORTED_FILTER_OPERATION, operation); - } - } - } else { - throw handleClientException(ERROR_CODE_BAD_VALUE_FOR_FILTER, filter); - } - } - return aliases; - } - - private KeyStoreAdmin getKeyStoreAdmin(String tenantDomain) { - - return new KeyStoreAdmin(IdentityTenantUtil.getTenantId(tenantDomain), - (Registry) CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE)); - } - - private boolean isSuperTenant(String tenantDomain) { - - return IdentityTenantUtil.getTenantId(tenantDomain) == MultitenantConstants.SUPER_TENANT_ID; - } - - private String getTrustStoreName() { - - ServerConfiguration serverConfiguration = ServerConfiguration.getInstance(); - String filePath = serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_FILE); - return Paths.get(filePath).getFileName().toString(); - } - - private KeyStoreManagementServerException handleServerException( - SecurityConstants.KeyStoreMgtConstants.ErrorMessage error, String data) { - - String message = includeData(error, data); - return new KeyStoreManagementServerException(error.getCode(), message); - } - - private KeyStoreManagementServerException handleServerException( - SecurityConstants.KeyStoreMgtConstants.ErrorMessage error, String data, - Throwable e) { - - String message = includeData(error, data); - return new KeyStoreManagementServerException(error.getCode(), message, e); - } - - private KeyStoreManagementClientException handleClientException( - SecurityConstants.KeyStoreMgtConstants.ErrorMessage error, String data) { - - String message = includeData(error, data); - return new KeyStoreManagementClientException(error.getCode(), message); - } - - private static String includeData(SecurityConstants.KeyStoreMgtConstants.ErrorMessage error, String data) { - - String message; - if (StringUtils.isNotBlank(data)) { - message = String.format(error.getMessage(), data); - } else { - message = error.getMessage(); - } - return message; - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/CertData.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/CertData.java deleted file mode 100644 index 08d6c7fa29a..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/CertData.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2005, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - -import java.math.BigInteger; - -/** - * This will provide cert as well as keystore important data. - */ -public class CertData { - - private String alias; - private String subjectDN; - private String issuerDN; - private BigInteger serialNumber; - private int version; - private String notBefore; - private String notAfter; - private String publicKey; - - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public String getSubjectDN() { - return subjectDN; - } - - public void setSubjectDN(String subjectDN) { - this.subjectDN = subjectDN; - } - - public String getIssuerDN() { - return issuerDN; - } - - public void setIssuerDN(String issuerDN) { - this.issuerDN = issuerDN; - } - - public BigInteger getSerialNumber() { - return serialNumber; - } - - public void setSerialNumber(BigInteger serialNumber) { - this.serialNumber = serialNumber; - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public String getNotBefore() { - return notBefore; - } - - public void setNotBefore(String notBefore) { - this.notBefore = notBefore; - } - - public String getNotAfter() { - return notAfter; - } - - public void setNotAfter(String notAfter) { - this.notAfter = notAfter; - } - - public String getPublicKey() { - return publicKey; - } - - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - -} - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/CertDataDetail.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/CertDataDetail.java deleted file mode 100644 index cdb1c90203b..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/CertDataDetail.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - -import java.security.cert.X509Certificate; - -public class CertDataDetail extends CertData { - private X509Certificate certificate; - - public X509Certificate getCertificate() { - return certificate; - } - - public void setCertificate(X509Certificate certificate) { - this.certificate = certificate; - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreAdminInterface.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreAdminInterface.java deleted file mode 100644 index 380dcd19bbb..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreAdminInterface.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - - -import org.wso2.carbon.security.SecurityConfigException; - -public interface KeyStoreAdminInterface { - - KeyStoreData[] getKeyStores() throws SecurityConfigException; - - void addKeyStore(String file, String filename, - String password, String provider, String type, String pvtkeyPass) throws SecurityConfigException; - - void addTrustStore(String file, String filename, - String password, String provider, String type) throws SecurityConfigException; - - void deleteStore(String keyStoreName) throws SecurityConfigException; - - void importCertToStore(String fileName, String fileData, String keyStoreName) throws SecurityConfigException; - - String[] getStoreEntries(String keyStoreName) throws SecurityConfigException; - - KeyStoreData getKeystoreInfo(String keyStoreName) throws SecurityConfigException; - - void removeCertFromStore(String alias, String keyStoreName) throws SecurityConfigException; - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreAdminServiceImpl.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreAdminServiceImpl.java deleted file mode 100644 index 69a847667a0..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreAdminServiceImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.core.AbstractAdmin; -import org.wso2.carbon.security.SecurityConfigException; -import org.wso2.carbon.security.keystore.KeyStoreAdmin; - -public class KeyStoreAdminServiceImpl extends AbstractAdmin implements KeyStoreAdminInterface { - - @Override - public KeyStoreData[] getKeyStores() throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - boolean isSuperTenant = CarbonContext.getThreadLocalCarbonContext().getTenantId() == - MultitenantConstants.SUPER_TENANT_ID; - return admin.getKeyStores(isSuperTenant); - } - - @Override - public void addKeyStore(String fileData, String filename, String password, String provider, - String type, String pvtkeyPass) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - admin.addKeyStore(fileData, filename, password, provider, type, pvtkeyPass); - } - - @Override - public void addTrustStore(String fileData, String filename, String password, String provider, - String type) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - admin.addTrustStore(fileData, filename, password, provider, type); - } - - @Override - public void deleteStore(String keyStoreName) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - admin.deleteStore(keyStoreName); - - } - - @Override - public void importCertToStore(String fileName, String fileData, String keyStoreName) - throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - admin.importCertToStore(fileName, fileData, keyStoreName); - - } - - @Override - public String[] getStoreEntries(String keyStoreName) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - return admin.getStoreEntries(keyStoreName); - - } - - @Override - public KeyStoreData getKeystoreInfo(String keyStoreName) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - return admin.getKeystoreInfo(keyStoreName); - - } - - @Override - public void removeCertFromStore(String alias, String keyStoreName) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - admin.removeCertFromStore(alias, keyStoreName); - } - - public PaginatedKeyStoreData getPaginatedKeystoreInfo(String keyStoreName, int pageNumber) throws SecurityConfigException { - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - return admin.getPaginatedKeystoreInfo(keyStoreName, pageNumber); - - } - - /** - * Calls method to get the keystore info using keystore name and its certificates filtered by the given filter. - * - * @param keyStoreName Keystore name. - * @param pageNumber Page number. - * @param filter Filter for certificate alias. - * @return Paginated keystore data with certificates. - * @throws SecurityConfigException - */ - public PaginatedKeyStoreData getFilteredPaginatedKeyStoreInfo(String keyStoreName, int pageNumber, - String filter) throws SecurityConfigException { - - KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext().getTenantId(), - getGovernanceSystemRegistry()); - return admin.getFilteredPaginatedKeyStoreInfo(keyStoreName, pageNumber, filter); - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreData.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreData.java deleted file mode 100644 index 1b4f9d93784..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/KeyStoreData.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - -public class KeyStoreData { - - private CertData[] certs; - private CertData key; - private String keyValue; - private String keyStoreName = null; - private String keyStoreType = null; - private String provider = null; - private String pubKeyFilePath = null; - private boolean isPrivateStore = false; - - public String getKeyStoreName() { - return keyStoreName; - } - - public void setKeyStoreName(String keyStoreName) { - this.keyStoreName = keyStoreName; - } - - public String getKeyStoreType() { - return keyStoreType; - } - - public void setKeyStoreType(String keyStoreType) { - this.keyStoreType = keyStoreType; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - public boolean getPrivateStore() { - return isPrivateStore; - } - - public void setPrivateStore(boolean isPrivateStore) { - this.isPrivateStore = isPrivateStore; - } - - public CertData[] getCerts() { - return certs; - } - - public void setCerts(CertData[] certs) { - this.certs = certs; - } - - public CertData getKey() { - return key; - } - - public void setKey(CertData key) { - this.key = key; - } - - public String getKeyValue() { - return keyValue; - } - - public void setKeyValue(String keyValue) { - this.keyValue = keyValue; - } - - public String getPubKeyFilePath() { - return pubKeyFilePath; - } - - public void setPubKeyFilePath(String pubKeyFilePath) { - this.pubKeyFilePath = pubKeyFilePath; - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/PaginatedCertData.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/PaginatedCertData.java deleted file mode 100644 index e1bc43084e6..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/PaginatedCertData.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - -import java.util.Arrays; - -public class PaginatedCertData { - private CertData[] certDataSet; - - private int numberOfPages; - - public CertData[] getCertDataSet() { - return Arrays.copyOf(certDataSet, certDataSet.length); - } - - public void setCertDataSet(CertData[] certDataSet) { - this.certDataSet = Arrays.copyOf(certDataSet, certDataSet.length); - } - - public int getNumberOfPages() { - return numberOfPages; - } - - public void setNumberOfPages(int numberOfPages) { - this.numberOfPages = numberOfPages; - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/PaginatedKeyStoreData.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/PaginatedKeyStoreData.java deleted file mode 100644 index 24b28c015b6..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/keystore/service/PaginatedKeyStoreData.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore.service; - -public class PaginatedKeyStoreData { - - private CertData key; - private String keyValue; - private String keyStoreName = null; - private String keyStoreType = null; - private String provider = null; - private String pubKeyFilePath = null; - private boolean isPrivateStore = false; - private PaginatedCertData paginatedCertData; - private PaginatedCertData paginatedKeyData; - - public PaginatedCertData getPaginatedKeyData() { - return paginatedKeyData; - } - - public void setPaginatedKeyData(PaginatedCertData paginatedKeyData) { - this.paginatedKeyData = paginatedKeyData; - } - - public String getKeyStoreName() { - return keyStoreName; - } - - public void setKeyStoreName(String keyStoreName) { - this.keyStoreName = keyStoreName; - } - - public String getKeyStoreType() { - return keyStoreType; - } - - public void setKeyStoreType(String keyStoreType) { - this.keyStoreType = keyStoreType; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - public boolean getPrivateStore() { - return isPrivateStore; - } - - public void setPrivateStore(boolean isPrivateStore) { - this.isPrivateStore = isPrivateStore; - } - - public CertData getKey() { - return key; - } - - public void setKey(CertData key) { - this.key = key; - } - - public String getKeyValue() { - return keyValue; - } - - public void setKeyValue(String keyValue) { - this.keyValue = keyValue; - } - - public String getPubKeyFilePath() { - return pubKeyFilePath; - } - - public void setPubKeyFilePath(String pubKeyFilePath) { - this.pubKeyFilePath = pubKeyFilePath; - } - - public PaginatedCertData getPaginatedCertData() { - return paginatedCertData; - } - - public void setPaginatedCertData(PaginatedCertData paginatedCertData) { - this.paginatedCertData = paginatedCertData; - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/PassiveSTSServiceInterface.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/PassiveSTSServiceInterface.java deleted file mode 100644 index 9d7ee2eb896..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/PassiveSTSServiceInterface.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.sts.service; - -/** - * Interface used to register PassiveSTSServiceImpl(a dummy service) in inbound-auth-sts. - * Purpose of having the dummy service is that the REST API can check if the service is - * available and make the responses appropriately. - */ -public interface PassiveSTSServiceInterface { -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/STSAdminServiceInterface.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/STSAdminServiceInterface.java deleted file mode 100644 index 51c7628be2a..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/STSAdminServiceInterface.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.sts.service; - -import org.wso2.carbon.security.SecurityConfigException; -import org.wso2.carbon.security.sts.service.util.TrustedServiceData; - -public interface STSAdminServiceInterface { - - /** - * Add a the given service end-point as a trusted end-point address - * - * @param serviceAddress Address of the service end-point - * @param certAlias Alias of the service certificate - * @throws SecurityConfigException - */ - public void addTrustedService(String serviceAddress, String certAlias) - throws SecurityConfigException; - - default void removeTrustedService(String serviceAddress) throws SecurityConfigException { - - } - - /** - * @return - * @throws SecurityConfigException - */ - public TrustedServiceData[] getTrustedServices() throws SecurityConfigException; - - /** - * @return - * @throws SecurityConfigException - */ - public String getProofKeyType() throws SecurityConfigException; - - /** - * @param keyType - * @throws SecurityConfigException - */ - public void setProofKeyType(String keyType) throws SecurityConfigException; - - /** - * @return - * @throws SecurityConfigException - */ - public String[] getCertAliasOfPrimaryKeyStore() throws SecurityConfigException; - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/util/STSServiceValidationUtil.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/util/STSServiceValidationUtil.java deleted file mode 100644 index 042b37aa457..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/util/STSServiceValidationUtil.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.wso2.carbon.security.sts.service.util; - -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.security.sts.service.STSAdminServiceInterface; - -/** - * Util class used to validate if the STS services are deployed. - * Used by Management Console UI to hide fields on service unavailability. - */ -public class STSServiceValidationUtil { - - /** - * Check if the WS-Trust service is deployed. - * - * @return True if the service is deployed false if else. - */ - public static boolean isWSTrustAvailable() { - - try { - STSAdminServiceInterface stsAdminService = - (STSAdminServiceInterface) PrivilegedCarbonContext.getThreadLocalCarbonContext() - .getOSGiService(STSAdminServiceInterface.class, null); - return stsAdminService != null; - } catch (NullPointerException exception) { - return false; - } - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/util/TrustedServiceData.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/util/TrustedServiceData.java deleted file mode 100644 index bf089ba3996..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/sts/service/util/TrustedServiceData.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.sts.service.util; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Trusted service information - */ -@XmlRootElement -@XmlAccessorType(XmlAccessType.FIELD) -public class TrustedServiceData implements Serializable { - - private static final long serialVersionUID = 8180341106812151691L; - - private String serviceAddress; - private String certAlias; - - /** - * Create a new data instance with the service address and cert alias - * - * @param serviceAddress Address of the trusted service - * @param certAlias Alias of the cert of the service - */ - public TrustedServiceData(String serviceAddress, String certAlias) { - - this.serviceAddress = serviceAddress; - this.certAlias = certAlias; - } - - public TrustedServiceData() { - - } - - public String getServiceAddress() { - - return serviceAddress; - } - - public String getCertAlias() { - - return certAlias; - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/util/KeyStoreMgtUtil.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/util/KeyStoreMgtUtil.java deleted file mode 100644 index 5dcdb02e10d..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/util/KeyStoreMgtUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.util; - -import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.identity.core.util.IdentityIOStreamUtils; -import org.wso2.carbon.utils.ServerConstants; -import org.wso2.carbon.utils.WSO2Constants; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.security.SecureRandom; -import java.util.Hashtable; -import java.util.Map; - -public class KeyStoreMgtUtil { - - private static final Log log = LogFactory.getLog(KeyStoreMgtUtil.class); - - private KeyStoreMgtUtil(){} - - /** - * Dumping the generated pub. cert to a file - * - * @param configurationContext - * @param cert content of the certificate - * @param fileName file name - * @return file system location of the pub. cert - */ - public static String dumpCert(ConfigurationContext configurationContext, byte[] cert, - String fileName) { - if (!verifyCertExistence(fileName, configurationContext)) { - String workDir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR); - File pubCert = new File(workDir + File.separator + "pub_certs"); - - if (fileName == null) { - fileName = String.valueOf(System.currentTimeMillis() + new SecureRandom().nextDouble()) + ".cert"; - } - if (!pubCert.exists()) { - pubCert.mkdirs(); - } - - String filePath = workDir + File.separator + "pub_certs" + File.separator + fileName; - OutputStream outStream = null; - try { - outStream = new FileOutputStream(filePath); - outStream.write(cert); - } catch (Exception e) { - String msg = "Error when writing the public certificate to a file"; - log.error(msg); - throw new SecurityException("msg", e); - } finally { - IdentityIOStreamUtils.flushOutputStream(outStream); - IdentityIOStreamUtils.closeOutputStream(outStream); - } - - Map fileResourcesMap = (Map) configurationContext.getProperty(WSO2Constants.FILE_RESOURCE_MAP); - if (fileResourcesMap == null) { - fileResourcesMap = new Hashtable(); - configurationContext.setProperty(WSO2Constants.FILE_RESOURCE_MAP, fileResourcesMap); - } - - fileResourcesMap.put(fileName, filePath); - } - return WSO2Constants.ContextPaths.DOWNLOAD_PATH + "?id=" + fileName; - } - - /** - * Check whether the certificate is available in the file system - * - * @param fileName file name - * @param configurationContext configuration context of the current message - */ - private static boolean verifyCertExistence(String fileName, ConfigurationContext configurationContext) { - String workDir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR); - String filePath = workDir + File.separator + "pub_certs" + File.separator + fileName; - File pubCert = new File(workDir + File.separator + "pub_certs" + File.separator + fileName); - - //if cert is still available then exit - if (pubCert.exists()) { - Map fileResourcesMap = (Map) configurationContext.getProperty(WSO2Constants.FILE_RESOURCE_MAP); - if (fileResourcesMap == null) { - fileResourcesMap = new Hashtable(); - configurationContext.setProperty(WSO2Constants.FILE_RESOURCE_MAP, fileResourcesMap); - } - if (fileResourcesMap.get(fileName) == null) { - fileResourcesMap.put(fileName, filePath); - } - return true; - } - return false; - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/util/SecurityPersistenceUtils.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/util/SecurityPersistenceUtils.java deleted file mode 100644 index d2c69957e0c..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/java/org/wso2/carbon/security/util/SecurityPersistenceUtils.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.util; - -import org.apache.axiom.om.OMAttribute; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.Resources; -import org.wso2.carbon.core.persistence.PersistenceDataNotFoundException; -import org.wso2.carbon.core.persistence.PersistenceUtils; -import org.wso2.carbon.core.persistence.file.ServiceGroupFilePersistenceManager; -import org.wso2.carbon.user.core.UserRealm; -import org.wso2.carbon.user.core.UserStoreException; - -import java.util.ArrayList; -import java.util.List; - -/** - * @deprecated Not for public use, has been replaced. - */ -@Deprecated -public class SecurityPersistenceUtils { - - private static final Log log = LogFactory.getLog(SecurityPersistenceUtils.class); - - /** - * @param serviceGroupId serviceGroupId - * @param serviceId serviceId - * @param realm realm - * @param tenantAwareUserName tenantAwareUserName - * @param permissionType Probably UserCoreConstants.INVOKE_SERVICE_PERMISSION is all you need for this - * @param serviceGroupFilePM serviceGroupFilePM - * @return false if any of the roles of user does not have permission to access it or no roles assigned for the service. - * @throws UserStoreException - * @deprecated do not use this method - */ - public static boolean isUserAuthorized( - String serviceGroupId, String serviceId, UserRealm realm, String tenantAwareUserName, String permissionType, - ServiceGroupFilePersistenceManager serviceGroupFilePM) throws UserStoreException { - try { - String[] rolesList = realm.getUserStoreManager().getRoleListOfUser(tenantAwareUserName); - - String serviceXPath = Resources.ServiceProperties.ROOT_XPATH + PersistenceUtils. - getXPathAttrPredicate(Resources.NAME, serviceId); - String rolesPath = serviceXPath + - "/" + Resources.SecurityManagement.ROLE_XML_TAG + - PersistenceUtils.getXPathAttrPredicate( - Resources.Associations.TYPE, permissionType) + - "/@" + Resources.SecurityManagement.ROLENAME_XML_ATTR; - - List tmpAllowedRolesAttr = serviceGroupFilePM.getAll(serviceGroupId, rolesPath); - List allowedRoles = new ArrayList<>(tmpAllowedRolesAttr.size()); - for (Object attr : tmpAllowedRolesAttr) { - allowedRoles.add(((OMAttribute) attr).getAttributeValue()); - } - - for (String role : rolesList) { - if (allowedRoles.contains(role)) { - return true; - } - } - return false; - } catch (PersistenceDataNotFoundException e) { - log.error("Error occurred while reading allowed roles element. Returning false.", e); - return false; - } - } -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/META-INF/component.xml b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/META-INF/component.xml deleted file mode 100644 index 07705c77194..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/META-INF/component.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - Key Store Management - /permission/admin/manage/identity/keystoremgt - - - - Create - /permission/admin/manage/identity/keystoremgt/create - - - View - /permission/admin/manage/identity/keystoremgt/view - - - Update - /permission/admin/manage/identity/keystoremgt/update - - - Delete - /permission/admin/manage/identity/keystoremgt/delete - - - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/META-INF/services.xml b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/META-INF/services.xml deleted file mode 100644 index 2d3e891a9dd..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/META-INF/services.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - https - - org.wso2.carbon.security.keystore.service.KeyStoreAdminServiceImpl - - - /permission/admin/manage/identity/keystoremgt/view - - - - /permission/admin/manage/identity/keystoremgt/create - - - - /permission/admin/manage/identity/keystoremgt/create - - - - /permission/admin/manage/identity/keystoremgt/delete - - - - /permission/admin/manage/identity/keystoremgt/create - - - - /permission/admin/manage/identity/keystoremgt/view - - - - /permission/admin/manage/identity/keystoremgt/view - - - - /permission/admin/manage/identity/keystoremgt/update - - - - /permission/admin/manage/identity/keystoremgt/view - - - /permission/admin/manage/identity/keystoremgt - - - true - true - diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/org/wso2/carbon/security/errors.properties b/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/org/wso2/carbon/security/errors.properties deleted file mode 100644 index d7e46852e52..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/main/resources/org/wso2/carbon/security/errors.properties +++ /dev/null @@ -1,64 +0,0 @@ -getKeyStores = Error retrieving KeyStores. -nullKeyStore = Provided KeyStore is invalid. -addKeyStore = Error adding KeyStore. Error is {0} -importCertToStore = Error importing certificate to store. Error is {0} -getStoreEntries = Error getting store entries. Error is {0} -deleteStore = Error deleting KeyStore. Error is {0} -nullAlias = Encountered a null alias -keystoreExist = The KeyStore {0} already exists. -deletePrimaryStore = Primary KeyStore cannot be deleted. -deleteStoreUsed = KeyStore is currently being used. Please delete this KeyStore from security scenarios and try again. - -nullUserStores = Provided user store is invalid. -getAllUserStoreNames = Error retrieving user stores. Error is {0} -getStoreTypeProperties = Error retrieving user store properties. Error is {0} -getUserStorePropertyValues = Error retrieving user store property values. Error is {0} -addUserStore = Error adding KeyStore. Error is {0} -getStoreUsers = Error getting user stores. Error is {0} -oldPasswordMismatch = Old password is incorrect -nullUser = Invalid user name provided -deleteUserStore = Error deleting user store. Error is {0} -readingUserstore = Error reading user store. Error is {0} -updatingUserstore = Error updating user store. Error is {0} -userStoreExist = The user store {0} already exists. Please pick another name. -userExist = The user {0} already exists. -systemErrorAuthenticatingUser = System error occurred while authenticating user. Details are : {0} -nullUserOrPass = Invalid user name or password provided - -getUserGroups = Error retrieving users in a group {0} -addUserGroup = Error adding users to group {0} -getUsesInGroup = Error retrieving users in a group {0} -deleteUserGroup = Error deleting user group {0} -userGroupExist = The user group {0} already exists. -deleteUserGroupUsed = User Group is currently being used. Please delete this user group from security scenarios and try again. -nullUserGroup = Invalid user group name provided - -cannotDelete = Cannot delete {0} -cannotEdit = Cannot edit {0} - -errorApplyingPolicy = Error applying policy -missingResource = Missing resource in registry : {0} -registryError = Unexpected registry error. {0} -errorDisengagingModules = Error disengaging modules - service : {0}, scenario : {1} -errorRemovingServicePolicies = Error removing service policies of service : {0} -errorSettingupSecurityPolicyAssertionBuilders = Error setting up security policy assertion builders -initializationError=Error initializing the org.wso2.carbon.security component -registryNotAvailable = WSO2 Registry is not available -nullService = Please provide a valid service -transportSwitch = Error while enable/disable transport -loadingPolicy = Error loading policy -creatingAuthenticator = Error creating authenticator -removingPolicy = Error removing policy -configuringService = Error configuring Axis Service : {0} -addingKeyPass = Couldn't add private key pass : {0} -missingks = KeyStore missing :{0} - -nullRegistryService = Registry service has not started - -connectionFailed = Connection to userstore failed. Reason {0} - -illegalChars = Illegal charactors in name. - -failToLoadKeyStore = Fail to load KeyStore : {0} - -deleteUserStoreUsed = User groups are defined using this User store. Delete the user groups and try again. \ No newline at end of file diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/java/org/wso2/carbon/security/keystore/KeyStoreAdminTest.java b/components/security-mgt/org.wso2.carbon.security.mgt/src/test/java/org/wso2/carbon/security/keystore/KeyStoreAdminTest.java deleted file mode 100644 index 3b1863f49ef..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/java/org/wso2/carbon/security/keystore/KeyStoreAdminTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.carbon.security.keystore; - -import org.mockito.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.base.CarbonBaseConstants; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.core.util.KeyStoreManager; -import org.wso2.carbon.core.util.KeyStoreUtil; -import org.wso2.carbon.identity.core.util.IdentityTenantUtil; -import org.wso2.carbon.identity.core.util.IdentityUtil; -import org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest; -import org.wso2.carbon.registry.core.Registry; -import org.wso2.carbon.security.keystore.service.CertData; -import org.wso2.carbon.security.keystore.service.PaginatedKeyStoreData; -import org.wso2.carbon.utils.CarbonUtils; - -import java.io.FileInputStream; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.KeyStore; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.Assert.assertEquals; - -@PrepareForTest({CarbonUtils.class, IdentityTenantUtil.class, IdentityUtil.class, KeyStoreManager.class, - ServerConfiguration.class, KeyStoreUtil.class}) -public class KeyStoreAdminTest extends PowerMockIdentityBaseTest { - - public static final String SERVER_TRUSTSTORE_FILE = "Security.TrustStore.Location"; - public static final String SERVER_TRUSTSTORE_PASSWORD = "Security.TrustStore.Password"; - @Mock - ServerConfiguration serverConfiguration; - @Mock - KeyStoreManager keyStoreManager; - @Mock - Registry registry; - private KeyStoreAdmin keyStoreAdmin; - private int tenantID = -1234; - - @BeforeClass - public void setup() { - - System.setProperty( - CarbonBaseConstants.CARBON_HOME, - Paths.get(System.getProperty("user.dir"), "src", "test", "resources").toString() - ); - } - - @Test - public void testGetPaginatedKeystoreInfo() throws Exception { - - mockStatic(ServerConfiguration.class); - when(ServerConfiguration.getInstance()).thenReturn(serverConfiguration); - - mockStatic(KeyStoreManager.class); - when(KeyStoreManager.getInstance(anyInt())).thenReturn(keyStoreManager); - when(keyStoreManager.getKeyStore("wso2carbon.jks")).thenReturn(getKeyStoreFromFile("wso2carbon.jks", - "wso2carbon")); - when(serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_FILE)).thenReturn(createPath("wso2carbon.jks").toString()); - when(serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_PASSWORD)).thenReturn("wso2carbon"); - - mockStatic(KeyStoreUtil.class); - when(KeyStoreUtil.isPrimaryStore(any())).thenReturn(true); - - mockStatic(KeyStoreManager.class); - when(KeyStoreManager.getInstance(tenantID)).thenReturn(keyStoreManager); - when(keyStoreManager.getPrimaryKeyStore()).thenReturn(getKeyStoreFromFile("wso2carbon.jks", "wso2carbon")); - - keyStoreAdmin = new KeyStoreAdmin(tenantID, registry); - PaginatedKeyStoreData result = keyStoreAdmin.getPaginatedKeystoreInfo("wso2carbon.jks", 10); - int actualKeysNo = findCertDataSetSize(result.getPaginatedKeyData().getCertDataSet()); - assertEquals(actualKeysNo, 3, "Incorrect key numbers"); - - } - - private KeyStore getKeyStoreFromFile(String keystoreName, String password) throws Exception { - - Path tenantKeystorePath = createPath(keystoreName); - FileInputStream file = new FileInputStream(tenantKeystorePath.toString()); - KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); - keystore.load(file, password.toCharArray()); - return keystore; - } - - private Path createPath(String keystoreName) { - - Path keystorePath = Paths.get(System.getProperty(CarbonBaseConstants.CARBON_HOME), "repository", - "resources", "security", keystoreName); - return keystorePath; - } - - private int findCertDataSetSize(CertData[] certDataSet) { - - int ans = 0; - for (CertData cert : certDataSet) { - if (cert != null) { - ans += 1; - } - } - return ans; - } - -} diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/repository/resources/security/foo-com.jks b/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/repository/resources/security/foo-com.jks deleted file mode 100644 index 1c3eb532cec..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/repository/resources/security/foo-com.jks and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/repository/resources/security/wso2carbon.jks b/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/repository/resources/security/wso2carbon.jks deleted file mode 100644 index d5af4f42973..00000000000 Binary files a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/repository/resources/security/wso2carbon.jks and /dev/null differ diff --git a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/testng.xml b/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/testng.xml deleted file mode 100644 index ccc588beafc..00000000000 --- a/components/security-mgt/org.wso2.carbon.security.mgt/src/test/resources/testng.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - diff --git a/components/security-mgt/pom.xml b/components/security-mgt/pom.xml deleted file mode 100644 index 73e7cfeb841..00000000000 --- a/components/security-mgt/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - identity-framework - 5.25.293-SNAPSHOT - ../../pom.xml - - - 4.0.0 - security-mgt - pom - WSO2 Carbon - Security Aggregator Module - http://wso2.org - - - org.wso2.carbon.security.mgt - org.wso2.carbon.security.mgt.ui - - - diff --git a/components/template-mgt/org.wso2.carbon.identity.template.mgt/pom.xml b/components/template-mgt/org.wso2.carbon.identity.template.mgt/pom.xml index af283973c03..19d3b81f451 100644 --- a/components/template-mgt/org.wso2.carbon.identity.template.mgt/pom.xml +++ b/components/template-mgt/org.wso2.carbon.identity.template.mgt/pom.xml @@ -162,7 +162,7 @@ org.wso2.carbon.identity.configuration.mgt.core - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt diff --git a/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/pom.xml b/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/pom.xml index 043ac9864df..bd77f74b485 100644 --- a/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/pom.xml @@ -66,7 +66,7 @@ org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} org.wso2.carbon.claim.mgt.server:compatible:${identity.framework.version} - org.wso2.carbon.security.mgt.server:compatible:${identity.framework.version} + org.wso2.carbon.security.mgt.server:compatible:${carbon.security.mgt.version} org.wso2.carbon.idp.mgt.server:compatible:${identity.framework.version} org.wso2.carbon.identity.core.server:compatible:${identity.framework.version} diff --git a/features/categories/keystore-mgt/pom.xml b/features/categories/keystore-mgt/pom.xml index d5e47db021d..64eda877155 100644 --- a/features/categories/keystore-mgt/pom.xml +++ b/features/categories/keystore-mgt/pom.xml @@ -55,7 +55,7 @@ - org.wso2.carbon.security.mgt:compatible:${identity.framework.version} + org.wso2.carbon.security.mgt:compatible:${carbon.security.mgt.version} diff --git a/features/identity-core/org.wso2.carbon.identity.core.server.feature/pom.xml b/features/identity-core/org.wso2.carbon.identity.core.server.feature/pom.xml index c3575b02804..f7cace8bf73 100644 --- a/features/identity-core/org.wso2.carbon.identity.core.server.feature/pom.xml +++ b/features/identity-core/org.wso2.carbon.identity.core.server.feature/pom.xml @@ -46,7 +46,7 @@ org.wso2.carbon.identity.application.common - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt.server.feature zip @@ -128,7 +128,7 @@ org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} - org.wso2.carbon.security.mgt.server:compatible:${identity.framework.version} + org.wso2.carbon.security.mgt.server:compatible:${carbon.security.mgt.version} diff --git a/features/identity-core/org.wso2.carbon.identity.core.ui.feature/pom.xml b/features/identity-core/org.wso2.carbon.identity.core.ui.feature/pom.xml index 26454f30e5f..1159b3ac0ca 100644 --- a/features/identity-core/org.wso2.carbon.identity.core.ui.feature/pom.xml +++ b/features/identity-core/org.wso2.carbon.identity.core.ui.feature/pom.xml @@ -71,7 +71,7 @@ org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} - org.wso2.carbon.security.mgt.server:compatible:${identity.framework.version} + org.wso2.carbon.security.mgt.server:compatible:${carbon.security.mgt.version} diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.feature/pom.xml b/features/security-mgt/org.wso2.carbon.security.mgt.feature/pom.xml deleted file mode 100644 index f5852c32707..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.feature/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - security-mgt-feature - 5.25.293-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.security.mgt.feature - pom - Key Store Management Feature - http://wso2.org - This feature contains the bundles required for Security Management functionality - - - - org.wso2.carbon.identity.framework - org.wso2.carbon.security.mgt.server.feature - zip - - - org.wso2.carbon.identity.framework - org.wso2.carbon.security.mgt.ui.feature - zip - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.security.mgt - ../../etc/feature.properties - - org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} - - - - org.wso2.carbon.identity.framework:org.wso2.carbon.security.mgt.server.feature - - org.wso2.carbon.identity.framework:org.wso2.carbon.security.mgt.ui.feature - - - - - - - - - - diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/pom.xml b/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/pom.xml deleted file mode 100644 index 91bebd9c72f..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - security-mgt-feature - 5.25.293-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.security.mgt.server.feature - pom - WSO2 Carbon - Security Management Core Feature - http://wso2.org - This feature contains the core bundles required for Back-end Security Management functionality - - - - - org.wso2.carbon.identity.framework - org.wso2.carbon.security.mgt - - - - - - - - - - - maven-resources-plugin - - - prefilter-resources - generate-resources - - copy-resources - - - src/main/resources - - - resources - - build.properties - conf/jaas.conf - conf/krb5.conf - p2.inf - - - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.security.mgt.server - ../../etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - - - - org.wso2.carbon.identity.framework:org.wso2.carbon.security.mgt - - - org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} - - - - - - - - - - diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/build.properties b/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/build.properties deleted file mode 100644 index 0ca84211b7c..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -custom = true -root.security-mgt=conf diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/conf/jaas.conf b/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/conf/jaas.conf deleted file mode 100644 index a53ffc008c4..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/conf/jaas.conf +++ /dev/null @@ -1,11 +0,0 @@ -Server { -com.sun.security.auth.module.Krb5LoginModule required -useKeyTab=false -storeKey=true -useTicketCache=false -isInitiator=false; -}; -Client { -com.sun.security.auth.module.Krb5LoginModule required -useTicketCache=false; -}; diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/conf/krb5.conf b/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/conf/krb5.conf deleted file mode 100644 index 202f298c4d5..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/conf/krb5.conf +++ /dev/null @@ -1,11 +0,0 @@ -[libdefaults] - default_realm = WSO2.COM - default_tkt_enctypes = rc4-hmac - default_tgs_enctypes = rc4-hmac - dns_lookup_kdc = true - dns_lookup_realm = false - -[realms] - WSO2.COM = { - kdc = 127.0.0.1 - } \ No newline at end of file diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/p2.inf b/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/p2.inf deleted file mode 100644 index 11ca6f86047..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.server.feature/src/main/resources/p2.inf +++ /dev/null @@ -1 +0,0 @@ -instructions.configure = org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.security.mgt.server_${feature.version}/conf/jaas.conf,target:${installFolder}/../../conf/jaas.conf,overwrite:true);org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.security.mgt.server_${feature.version}/conf/krb5.conf,target:${installFolder}/../../conf/krb5.conf,overwrite:true);\ \ No newline at end of file diff --git a/features/security-mgt/org.wso2.carbon.security.mgt.ui.feature/pom.xml b/features/security-mgt/org.wso2.carbon.security.mgt.ui.feature/pom.xml deleted file mode 100644 index 1c7c42fcf33..00000000000 --- a/features/security-mgt/org.wso2.carbon.security.mgt.ui.feature/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - security-mgt-feature - 5.25.293-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.security.mgt.ui.feature - pom - WSO2 Carbon - Security Management UI Feature - http://wso2.org - This feature contains the bundles required for Front-end Security Management functionality - - - - - org.wso2.carbon.identity.framework - org.wso2.carbon.security.mgt.ui - - - org.wso2.carbon.identity.framework - org.wso2.carbon.security.mgt.stub - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.security.mgt.ui - ../../etc/feature.properties - - - org.wso2.carbon.p2.category.type:console - org.eclipse.equinox.p2.type.group:false - - - - org.wso2.carbon.identity.framework:org.wso2.carbon.security.mgt.ui - org.wso2.carbon.identity.framework:org.wso2.carbon.security.mgt.stub - - - org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} - - - - - - - - - diff --git a/features/security-mgt/pom.xml b/features/security-mgt/pom.xml deleted file mode 100644 index 1f1eb66093c..00000000000 --- a/features/security-mgt/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - identity-framework - 5.25.293-SNAPSHOT - ../../pom.xml - - - 4.0.0 - security-mgt-feature - pom - WSO2 Carbon - Security Management Feature Aggregator Module - http://wso2.org - - - org.wso2.carbon.security.mgt.feature - org.wso2.carbon.security.mgt.server.feature - org.wso2.carbon.security.mgt.ui.feature - - - - diff --git a/features/xacml/org.wso2.carbon.identity.xacml.server.feature/pom.xml b/features/xacml/org.wso2.carbon.identity.xacml.server.feature/pom.xml index 78f87c59dbf..480fc629da5 100644 --- a/features/xacml/org.wso2.carbon.identity.xacml.server.feature/pom.xml +++ b/features/xacml/org.wso2.carbon.identity.xacml.server.feature/pom.xml @@ -167,7 +167,7 @@ org.wso2.carbon.identity.saml.common.util:${saml.common.util.version} org.wso2.carbon.core:compatible:${carbon.kernel.feature.version} org.wso2.carbon.identity.core.server:compatible:${identity.framework.version} - org.wso2.carbon.security.mgt.server:compatible:${identity.framework.version} + org.wso2.carbon.security.mgt.server:compatible:${carbon.security.mgt.version} org.wso2.carbon.identity.notification.mgt.server:compatible:${identity.framework.version} diff --git a/pom.xml b/pom.xml index 4daad67ad7c..2a8f601684b 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,6 @@ components/idp-mgt components/claim-mgt components/directory-server-manager - components/security-mgt components/workflow-mgt components/policy-editor components/carbon-authenticators @@ -72,7 +71,6 @@ components/input-validation-mgt features/extension-mgt components/consent-server-configs-mgt - features/security-mgt features/claim-mgt features/identity-core features/identity-event @@ -364,14 +362,14 @@ zip - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt - ${project.version} + ${carbon.security.mgt.version} - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt.ui - ${project.version} + ${carbon.security.mgt.version} org.wso2.carbon.identity.framework @@ -379,21 +377,21 @@ ${project.version} - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt.feature - ${project.version} + ${carbon.security.mgt.version} zip - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt.server.feature - ${project.version} + ${carbon.security.mgt.version} zip - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt.ui.feature - ${project.version} + ${carbon.security.mgt.version} zip @@ -457,9 +455,9 @@ - org.wso2.carbon.identity.framework + org.wso2.carbon.security.mgt org.wso2.carbon.security.mgt.stub - ${project.version} + ${carbon.security.mgt.version} junit @@ -1811,6 +1809,11 @@ [1.0.0, 2.0.0) + + 1.0.0 + [1.0.0,2.0.0) + ${carbon.security.mgt.version} + 4.8.12 [0.0.0,1.0.0) diff --git a/service-stubs/identity/org.wso2.carbon.security.mgt.stub/pom.xml b/service-stubs/identity/org.wso2.carbon.security.mgt.stub/pom.xml deleted file mode 100644 index 2352e6fa497..00000000000 --- a/service-stubs/identity/org.wso2.carbon.security.mgt.stub/pom.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - org.wso2.carbon.identity.framework - carbon-service-stubs - 5.25.293-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.security.mgt.stub - bundle - WSO2 Carbon - Security Stub - http://wso2.org - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - - org.wso2.carbon.identity.base.xsd.* ; - version="${carbon.identity.package.export.version}", - org.wso2.carbon.identity.sts.common.stub.config.* ; - version="${carbon.identity.package.export.version}", - org.wso2.carbon.security.mgt.stub.*; - version="${carbon.identity.package.export.version}" - - * - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.1 - - - source-code-generation - process-resources - - run - - - - - - - - - - - - - - - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - - target/generated-code/src - - - - - - - - - - - - org.apache.axis2.wso2 - axis2 - - - wsdl4j.wso2 - wsdl4j - - - org.wso2.orbit.org.apache.neethi - neethi - - - org.apache.neethi - neethi - - - - - org.ops4j.pax.logging - pax-logging-api - - - org.apache.ws.commons.axiom.wso2 - axiom - - - org.apache.axis2.wso2 - axis2-client - - - - diff --git a/service-stubs/identity/org.wso2.carbon.security.mgt.stub/src/main/resources/KeyStoreAdmin.wsdl b/service-stubs/identity/org.wso2.carbon.security.mgt.stub/src/main/resources/KeyStoreAdmin.wsdl deleted file mode 100644 index d79f30f83a1..00000000000 --- a/service-stubs/identity/org.wso2.carbon.security.mgt.stub/src/main/resources/KeyStoreAdmin.wsdl +++ /dev/null @@ -1,651 +0,0 @@ - - KeyStoreAdminService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/service-stubs/identity/org.wso2.carbon.security.mgt.stub/src/main/resources/SecurityConfigAdmin.wsdl b/service-stubs/identity/org.wso2.carbon.security.mgt.stub/src/main/resources/SecurityConfigAdmin.wsdl deleted file mode 100644 index 3238f0f0de2..00000000000 --- a/service-stubs/identity/org.wso2.carbon.security.mgt.stub/src/main/resources/SecurityConfigAdmin.wsdl +++ /dev/null @@ -1,535 +0,0 @@ - - - SecurityAdminService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/service-stubs/identity/pom.xml b/service-stubs/identity/pom.xml index f0debe27ea2..b46d302c120 100644 --- a/service-stubs/identity/pom.xml +++ b/service-stubs/identity/pom.xml @@ -32,7 +32,6 @@ http://wso2.org - org.wso2.carbon.security.mgt.stub org.wso2.carbon.claim.mgt.stub org.wso2.carbon.identity.claim.metadata.mgt.stub org.wso2.carbon.identity.application.mgt.stub