示例#1
0
  public SAMLAssertion authenticate(Credential credential)
      throws AuthenticationProviderException, CredentialNotSupportedException,
          InsufficientAttributeException, InvalidCredentialException {
    if (!AuthenticationProfile.isSupported(
        this.auth.getSupportedAuthenticationProfiles(), credential)) {
      CredentialNotSupportedException fault =
          FaultHelper.createFaultException(
              CredentialNotSupportedException.class,
              "The credential provided is not accepted by this service.");
      throw fault;
    }

    try {
      return this.auth.authenticate(credential);
    } catch (InvalidCredentialException ex) {
      InvalidCredentialException fault =
          FaultHelper.createFaultException(InvalidCredentialException.class, ex.getMessage());
      FaultHelper.addCause(fault, ex.getFault());
      throw fault;
    } catch (InsufficientAttributeException ex) {
      InsufficientAttributeException fault =
          FaultHelper.createFaultException(InsufficientAttributeException.class, ex.getMessage());
      FaultHelper.addCause(fault, ex.getFault());
      throw fault;
    } catch (Exception ex) {
      AuthenticationProviderException fault =
          FaultHelper.createFaultException(AuthenticationProviderException.class, ex.getMessage());
      throw fault;
    }
  }
示例#2
0
  public org.cagrid.gaards.authentication.service.SAMLAssertion authenticate(
      org.cagrid.gaards.authentication.service.Credential credential)
      throws InvalidCredentialException, InsufficientAttributeException,
          AuthenticationProviderException {
    if (credential.getBasicAuthenticationCredential() != null) {
      if (credential.getCredentialExtension() != null) {
        InvalidCredentialException fault =
            FaultHelper.createFaultException(
                InvalidCredentialException.class,
                "The credential extension cannot be used to authenticate with the deprecated authenticate method, only a basic authentication credential is supported.");
        throw fault;
      } else {
        BasicAuthenticationCredential cred = credential.getBasicAuthenticationCredential();
        BasicAuthentication auth = new BasicAuthentication();
        auth.setUserId(cred.getUserId());
        auth.setPassword(cred.getPassword());
        try {
          SAMLAssertion saml = this.authenticate(auth);
          org.cagrid.gaards.authentication.service.SAMLAssertion assertion =
              new org.cagrid.gaards.authentication.service.SAMLAssertion();
          assertion.setXml(SAMLUtils.samlAssertionToString(saml));
          return assertion;
        } catch (InsufficientAttributeException e) {
          InsufficientAttributeException fault =
              FaultHelper.createFaultException(
                  InsufficientAttributeException.class, e.getMessage());
          FaultHelper.addCause(fault, e.getFault());
          throw fault;
        } catch (InvalidCredentialException e) {
          InvalidCredentialException fault =
              FaultHelper.createFaultException(InvalidCredentialException.class, e.getMessage());
          FaultHelper.addCause(fault, e.getFault());
          throw fault;
        } catch (Exception e) {
          AuthenticationProviderException fault =
              FaultHelper.createFaultException(
                  AuthenticationProviderException.class, e.getMessage());
          throw fault;
        }
      }

    } else {
      InvalidCredentialException fault =
          FaultHelper.createFaultException(
              InvalidCredentialException.class,
              "No basic authentication credential was provided, a basic authentication credential is required to authenticate to this service using the deprecated authenticate method.");
      throw fault;
    }
  }