예제 #1
0
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#toString()
  */
 @Override
 public String toString() {
   StringBuilder result = new StringBuilder();
   result.append("Principal: " + getPrincipal() + ", Attributes: ");
   for (AttributeStatement attributeStatement : getAttributeStatements()) {
     for (Attribute attr : attributeStatement.getAttributes()) {
       result.append("[ ");
       result.append(attr.getName());
       result.append(" : ");
       for (int i = 0; i < attr.getAttributeValues().size(); i++) {
         result.append(((XSString) attr.getAttributeValues().get(i)).getValue());
       }
       result.append("] ");
     }
   }
   // add this back in when we support parsing this information
   result.append(", AuthnStatements: ");
   for (AuthnStatement authStatement : getAuthnStatements()) {
     result.append("[ ");
     result.append(authStatement.getAuthnInstant() + " : ");
     result.append(
         authStatement.getAuthnContext().getAuthnContextClassRef().getAuthnContextClassRef());
     result.append("] ");
   }
   //        result.append(", AuthzDecisionStatements: ");
   //        for (AuthzDecisionStatement authDecision : getAuthzDecisionStatements()) {
   //            result.append("[ ");
   //            result.append(authDecision.getDecision().toString());
   //            result.append(" ]");
   //        }
   return result.toString();
 }
예제 #2
0
 /*
  * (non-Javadoc)
  *
  * @see ddf.security.assertion.SecurityAssertion#getPrincipal()
  */
 @Override
 public Principal getPrincipal() {
   if (securityToken != null) {
     if (principal == null || !principal.getName().equals(name)) {
       String authMethod = null;
       if (authenticationStatements != null) {
         for (AuthnStatement authnStatement : authenticationStatements) {
           AuthnContext authnContext = authnStatement.getAuthnContext();
           if (authnContext != null) {
             AuthnContextClassRef authnContextClassRef = authnContext.getAuthnContextClassRef();
             if (authnContextClassRef != null) {
               authMethod = authnContextClassRef.getAuthnContextClassRef();
             }
           }
         }
       }
       if (SAML2Constants.AUTH_CONTEXT_CLASS_REF_X509.equals(authMethod)
           || SAML2Constants.AUTH_CONTEXT_CLASS_REF_SMARTCARD_PKI.equals(authMethod)
           || SAML2Constants.AUTH_CONTEXT_CLASS_REF_SOFTWARE_PKI.equals(authMethod)
           || SAML2Constants.AUTH_CONTEXT_CLASS_REF_SPKI.equals(authMethod)
           || SAML2Constants.AUTH_CONTEXT_CLASS_REF_TLS_CLIENT.equals(authMethod)) {
         principal = new X500Principal(name);
       } else if (SAML2Constants.AUTH_CONTEXT_CLASS_REF_KERBEROS.equals(authMethod)) {
         principal = new KerberosPrincipal(name);
       } else if (principal instanceof GuestPrincipal
           || name.startsWith(GuestPrincipal.GUEST_NAME_PREFIX)) {
         principal = new GuestPrincipal(name);
       } else {
         principal = new AssertionPrincipal(name);
       }
     }
     return principal;
   }
   return null;
 }