Package org.platformlayer.auth.v1

Examples of org.platformlayer.auth.v1.CheckServiceAccessRequest


      throws PlatformlayerAuthenticationClientException {
    if (username == null) {
      throw new IllegalArgumentException();
    }

    CertificateCredentials certificateCredentials = new CertificateCredentials();
    certificateCredentials.setUsername(username);

    Auth auth = new Auth();
    auth.setCertificateCredentials(certificateCredentials);

    AuthenticateRequest request = new AuthenticateRequest();
    request.setAuth(auth);

    final KeyManager keyManager = new SimpleClientCertificateKeyManager(privateKey, certificateChain);

    for (int i = 0; i < 2; i++) {
      AuthenticateResponse response;
      try {
        RestfulRequest<AuthenticateResponse> httpRequest = httpClient.buildRequest(HttpMethod.POST,
            "api/tokens", HttpPayload.asXml(request), AuthenticateResponse.class);

        httpRequest.setKeyManager(keyManager);

        response = httpRequest.execute();
      } catch (RestClientException e) {
        throw new PlatformlayerAuthenticationClientException("Error authenticating", e);
      }

      if (i == 0) {
        if (response == null || response.getChallenge() == null) {
          return null;
        }

        byte[] challenge = response.getChallenge();
        byte[] challengeResponse = decrypt(privateKey, challenge);
        certificateCredentials.setChallengeResponse(challengeResponse);
      } else {
        if (response == null || response.getAccess() == null) {
          return null;
        }
        return new PlatformlayerAuthenticationToken(response.getAccess());
View Full Code Here


public class CertificateChains {
  public static CertificateChainInfo toModel(X509Certificate[] chain) {
    CertificateChainInfo chainInfo = new CertificateChainInfo();
    List<CertificateInfo> certificates = chainInfo.getCertificates();
    for (X509Certificate cert : chain) {
      CertificateInfo certificateInfo = new CertificateInfo();

      certificateInfo.setSubjectDN(Certificates.getSubject(cert));
      Md5Hash hash = OpenSshUtils.getSignature(cert.getPublicKey());
      certificateInfo.setPublicKeyHash(hash.toHex());

      byte[] data = cert.getPublicKey().getEncoded();
      certificateInfo.setPublicKey(Hex.toHex(data));

      certificates.add(certificateInfo);
    }

    return chainInfo;
View Full Code Here

  }

  public String checkServiceAccess(CertificateChainInfo chain) {
    String url = "services/check";

    CheckServiceAccessRequest request = new CheckServiceAccessRequest();
    request.setChain(chain);

    try {
      CheckServiceAccessResponse response = doSimpleXmlRequest(HttpMethod.POST, url, request,
          CheckServiceAccessResponse.class);
View Full Code Here

    CheckServiceAccessRequest request = new CheckServiceAccessRequest();
    request.setChain(chain);

    try {
      CheckServiceAccessResponse response = doSimpleXmlRequest(HttpMethod.POST, url, request,
          CheckServiceAccessResponse.class);

      return response.getServiceAccount();
    } catch (RestClientException e) {
      throw new IllegalArgumentException("Error while checking service access", e);
    }
  }
View Full Code Here

  }

  @Override
  public PlatformlayerAuthenticationToken authenticateWithPassword(String username, String password)
      throws PlatformlayerAuthenticationClientException {
    PasswordCredentials passwordCredentials = new PasswordCredentials();
    passwordCredentials.setUsername(username);
    passwordCredentials.setPassword(password);

    // TODO: Cache auth tokens??
    AuthenticateResponse response = keystoneUserClient.authenticate(passwordCredentials);
    PlatformlayerAuthenticationToken authToken = new PlatformlayerAuthenticationToken(response.getAccess());
View Full Code Here

  }

  @Override
  public AuthenticationToken getAuthenticationToken() throws PlatformlayerAuthenticationClientException {
    if (token == null) {
      PasswordCredentials passwordCredentials = new PasswordCredentials();
      passwordCredentials.setUsername(username);
      passwordCredentials.setPassword(password);

      AuthenticateResponse response = client.authenticate(passwordCredentials);
      token = new PlatformlayerAuthenticationToken(response.getAccess());
    }
    return token;
View Full Code Here

      UserValidation userInfo = access.getUser();
      if (userInfo == null) {
        return null;
      }

      ProjectValidation projectInfo = access.getProject();
      if (projectInfo == null) {
        return null;
      }

      // List<String> roles = Lists.newArrayList();
View Full Code Here

      UserValidation userInfo = access.getUser();
      if (userInfo == null) {
        return null;
      }

      ProjectValidation projectInfo = access.getProject();
      if (projectInfo == null) {
        return null;
      }

      String userKey = userInfo.getName();
View Full Code Here

  // This can actually be moved to the user-auth system
  public List<X509Certificate> signCsr(String projectKey, CryptoKey projectSecret, String csr) {
    String url = "pki/csr";

    SignCertificateRequest request = new SignCertificateRequest();
    request.setProject(projectKey);
    request.setCsr(csr);
    request.setProjectSecret(FathomdbCrypto.serialize(projectSecret));

    try {
      SignCertificateResponse response = doSimpleXmlRequest(HttpMethod.POST, url, request,
          SignCertificateResponse.class);
View Full Code Here

    request.setProject(projectKey);
    request.setCsr(csr);
    request.setProjectSecret(FathomdbCrypto.serialize(projectSecret));

    try {
      SignCertificateResponse response = doSimpleXmlRequest(HttpMethod.POST, url, request,
          SignCertificateResponse.class);

      List<X509Certificate> certificates = Lists.newArrayList();
      for (String cert : response.getCertificates()) {
        certificates.addAll(CertificateUtils.fromPem(cert));
      }

      return certificates;
    } catch (RestClientException e) {
View Full Code Here

TOP

Related Classes of org.platformlayer.auth.v1.CheckServiceAccessRequest

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.