Ejemplo n.º 1
0
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#toString()
  */
 @Override
 public String toString() {
   StringBuilder result = new StringBuilder();
   result.append("Principal: ");
   result.append(getPrincipal());
   result.append(", 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(" : ");
     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();
 }
Ejemplo n.º 2
0
  @Override
  public Set<Principal> getPrincipals() {
    Set<Principal> principals = new HashSet<>();
    Principal primary = getPrincipal();
    principals.add(primary);
    principals.add(new RolePrincipal(primary.getName()));
    for (AttributeStatement attributeStatement : getAttributeStatements()) {
      for (Attribute attr : attributeStatement.getAttributes()) {
        if (StringUtils.containsIgnoreCase(attr.getName(), "role")) {
          for (final XMLObject obj : attr.getAttributeValues()) {
            principals.add(new RolePrincipal(((XSString) obj).getValue()));
          }
        }
      }
    }

    return principals;
  }
Ejemplo n.º 3
0
 /**
  * Checks if the NameIDFormat is of the following formats below, if not, the name is changed to
  * the value of the first matching usernameAttribute.
  */
 private void identifyNameIDFormat() {
   if (!((StringUtils.containsIgnoreCase(nameIDFormat, SAML2Constants.NAMEID_FORMAT_PERSISTENT)
           || StringUtils.containsIgnoreCase(
               nameIDFormat, SAML2Constants.NAMEID_FORMAT_X509_SUBJECT_NAME)
           || StringUtils.containsIgnoreCase(nameIDFormat, SAML2Constants.NAMEID_FORMAT_KERBEROS)
           || StringUtils.containsIgnoreCase(
               nameIDFormat, SAML2Constants.NAMEID_FORMAT_UNSPECIFIED))
       && !name.equals(""))) {
     for (AttributeStatement attributeStatementList : getAttributeStatements()) {
       List<Attribute> attributeList = attributeStatementList.getAttributes();
       for (Attribute attribute : attributeList) {
         if (listContainsIgnoreCase(usernameAttributeList, attribute.getName())) {
           name = ((XMLString) attribute.getAttributeValues().get(0)).getValue();
           return;
         }
       }
     }
   }
 }