Package org.wso2.carbon.security

Examples of org.wso2.carbon.security.SecurityConfigException


                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }

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


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

                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }

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

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

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

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

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

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

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

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

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

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

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

  }
View Full Code Here

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

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

                OMElement samlConfigElem = origParam.getParameterElement().getFirstChildWithName(
                        SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG);
                SAMLTokenIssuerConfig samlConfig = new SAMLTokenIssuerConfig(samlConfigElem);
                return samlConfig.getProofKeyType();
            } else {
                throw new SecurityConfigException("missing parameter : "
                        + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
            }
        } catch (Exception e) {
            log.error("Error while retrieving proof key type", e);
            throw new SecurityConfigException(e.getMessage(), e);
        }
    }
View Full Code Here

        }
        if (primaryKeystore != null) {
            return getStoreEntries(primaryKeystore.getKeyStoreName());
        }

        throw new SecurityConfigException("Primary Keystore cannot be found.");
    }
View Full Code Here

                resource.addProperty(trustedService, certAlias);
                registry.put(resourcePath, resource);
            }
        } catch (Exception e) {
            log.error("Error occured while adding trusted service for STS", e);
            throw new SecurityConfigException("Error occured while adding trusted service for STS",
                    e);
        }
    }
View Full Code Here

                    registry.put(resourcePath, resource);
                }
            }
        } catch (Exception e) {
            log.error("Error occured while removing trusted service for STS", e);
            throw new SecurityConfigException("Error occured while adding trusted service for STS",
                    e);
        }
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.security.SecurityConfigException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.