Package com.alu.e3.data.model

Examples of com.alu.e3.data.model.Certificate


  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
      exchange.setProperty(ExchangeConstantKeys.E3_API.toString(), api);   
    }
    else {
      Exception exception = new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Not Authorized from this IP address");
      exchange.setException(exception);     
View Full Code Here


    this.apiId = apiId;
  }
 
  @Override
  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
View Full Code Here

    Map<String, String> properties = (Map<String,String>) exchange.getProperty(ExchangeConstantKeys.E3_MODEL_PROPERTIES.toString());
    if(properties == null)
      properties = new HashMap<String, String>();

    // First add the TDRs from the API
    Api api = identity.getApi();
    if (api != null)
      if(doStatic)
        processTdrGenerationRuleStatic(api.getTdrGenerationRule(), exchange, properties);
      else
        processTdrGenerationRuleDynamic(api.getTdrGenerationRule(), exchange, properties, efType);

    // Next add all of the tdr values for the Policies
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
View Full Code Here


  protected List<CallDescriptor> checkSubscriberIdAuth(String subscriberId, AuthIdentity authIdentity) throws GatewayException {

    // Get subscriber matching CallDescriptors
    Auth auth;
    try {
      auth = dataManager.getAuthById(subscriberId);
    } catch (InvalidIDException e) {
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, e.getMessage() );
    }

    if (auth == null || !auth.getStatus().isActive()) {
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Authorization status is invalid");
    }

    return   dataManager.getMatchingPolicies(authIdentity.getApi(), auth);
View Full Code Here

          processTdrGenerationRuleDynamic(policy.getTdrGenerationRule(), exchange, properties, efType);
      }
    }

    // Finally add the values from the Auth
    Auth auth = identity.getAuth();
    if(auth != null)
      if(doStatic)
        processTdrGenerationRuleStatic(auth.getTdrGenerationRule(), exchange, properties);
      else
        processTdrGenerationRuleDynamic(auth.getTdrGenerationRule(), exchange, properties, efType);
  }
View Full Code Here

    Map<String, String> props = new HashMap<String,String>();

    props.putAll(identity.getApi().getProperties());
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
      Policy policy = cd.getPolicy();
      if(policy != null){
        props.putAll(policy.getProperties());
      }
    }
View Full Code Here

        processTdrGenerationRuleDynamic(api.getTdrGenerationRule(), exchange, properties, efType);

    // Next add all of the tdr values for the Policies
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
      Policy policy = cd.getPolicy();
      if(policy != null){
        if(doStatic)
          processTdrGenerationRuleStatic(policy.getTdrGenerationRule(), exchange, properties);
        else
          processTdrGenerationRuleDynamic(policy.getTdrGenerationRule(), exchange, properties, efType);
View Full Code Here


  public static final Certificate toDataModel(SSLCert sslCert){
    if(sslCert == null) throw new IllegalArgumentException("cert must not be null");

    Certificate cert = new Certificate();
    cert.setData(sslCert.getContent());
    cert.setId(sslCert.getId());
    cert.setPassword(sslCert.getKeyId());

    CertificateDetail cd = new CertificateDetail();
    cd.setId(sslCert.getId());
    cd.setKeyId(sslCert.getKeyId());
    cd.setName(sslCert.getDisplayName());

    cert.setCertDetail(cd);

    return cert;
  }
View Full Code Here

    }
  }
 
  private void doKeyStoreUpdate(DataEntryEvent<String, Key> event) {
    final Key key = event.getValue();
    Certificate cert = null;
    if(key.getActiveCertId() != null && key.getActiveCertId().length() > 0) {
      try {
        cert = dataManager.getCertById(key.getActiveCertId());       
      }
      catch (InvalidIDException e) {
        LOG.error("Certificate not found "+key.getActiveCertId(), e);
        throw new RuntimeException("Certificate not found "+key.getActiveCertId());
      }
    }
   
    if(cert == null){
      // A key has been uploaded without a certificate. Don't add it to the keystore.
      // This is a standard use-case. Don't error.     
      return;
    }

    PrivateKey jkey = null;
    java.security.cert.Certificate jcert = null;
   
    try {
     
      PasswordFinder passwordFinder = null;
     
      if (key.getKeyPassphrase() != null) {
        passwordFinder = new PasswordFinder() {
         
          @Override
          public char[] getPassword() {
            return key.getKeyPassphrase().toCharArray();
          }
        };
      }
     
      PEMReader pemr = new PEMReader(new StringReader(key.getData()), passwordFinder);
      Object pemobj = pemr.readObject();
      if(pemobj instanceof KeyPair){
        jkey = ((KeyPair)pemobj).getPrivate();
      } else if (pemobj instanceof PrivateKey){
        jkey = (PrivateKey)pemobj;
      } else {
        LOG.error("The PEM object in Key "+key.getId()+" is not a Private Key");
        throw new RuntimeException("The PEM object in Key "+key.getId()+" is not a Private Key");
      }
    } catch(IOException e){
      LOG.error("Failed to read Key "+key.getId()+" data.", e);
      throw new RuntimeException("Failed to read Key "+key.getId()+" data.");
    }
   
    try{
      PEMReader pemr = new PEMReader(new StringReader(cert.getData()));
      Object pemobj = pemr.readObject();
      if(pemobj instanceof java.security.cert.Certificate){
        jcert = (java.security.cert.Certificate)pemobj;
      } else {
        LOG.error("The PEM object in Certificate "+cert.getId()+" is not a Certificate");
        throw new RuntimeException("The PEM object in Certificate "+cert.getId()+" is not a Certificate");
      }
    } catch(IOException e){
      LOG.error("Failed to read Certificate "+cert.getId()+" data.", e);
      throw new RuntimeException("Failed to read Certificate "+cert.getId()+" data.");
    }
   
    synchronized(keyStoreService) {
     
      KeyStore ks = keyStoreService.loadKeyStore();
View Full Code Here

        if(LOG.isDebugEnabled())
          LOG.debug("Creating SSLCert ID:", cert.getId());
       
        cert.setKeyId(keyId);
       
        Certificate certificate = BeanConverterUtil.toDataModel(cert);
        dataManager.addCert(certificate);
     
        SSLCertResponse response = new SSLCertResponse(SSLCertResponse.SUCCESS);
       
        response.setId(cert.getId());
View Full Code Here

TOP

Related Classes of com.alu.e3.data.model.Certificate

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.