/** * Get an AttributeStatementBean using the given parameters. */ public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { AttributeStatementBean attrBean = new AttributeStatementBean(); List<AttributeBean> attributeList = new ArrayList<>(); TokenRequirements tokenRequirements = providerParameters.getTokenRequirements(); String tokenType = tokenRequirements.getTokenType(); AttributeBean attributeBean = createDefaultAttribute(tokenType); attributeList.add(attributeBean); attrBean.setSamlAttributes(attributeList); return attrBean; }
/** * Get an AttributeStatementBean using the given parameters. */ public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { AttributeStatementBean attrBean = new AttributeStatementBean(); List<AttributeBean> attributeList = new ArrayList<>(); TokenRequirements tokenRequirements = providerParameters.getTokenRequirements(); String tokenType = tokenRequirements.getTokenType(); AttributeBean attributeBean = createDefaultAttribute(tokenType); attributeList.add(attributeBean); attrBean.setSamlAttributes(attributeList); return attrBean; }
public AttributeStatementBean handleClaims(JsonMapObject claims) { if (claims != null) { String role = claims.getStringProperty("role"); if (role != null) { AttributeStatementBean attrBean = new AttributeStatementBean(); AttributeBean attributeBean = new AttributeBean(); attributeBean.setQualifiedName(ROLE.toString()); attributeBean.setNameFormat(nameFormat); List<Object> attributes = new ArrayList<>(); attributes.add(role); attributeBean.setAttributeValues(attributes); attrBean.setSamlAttributes(Collections.singletonList(attributeBean)); return attrBean; } } return null; }
public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { // Handle Claims ProcessedClaimCollection retrievedClaims = ClaimsUtils.processClaims(providerParameters); if (retrievedClaims == null) { return null; } Iterator<ProcessedClaim> claimIterator = retrievedClaims.iterator(); if (!claimIterator.hasNext()) { return null; } Map<AttributeKey, AttributeBean> attributeMap = new LinkedHashMap<>(); String tokenType = providerParameters.getTokenRequirements().getTokenType(); boolean saml2 = WSS4JConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType) || WSS4JConstants.SAML2_NS.equals(tokenType); while (claimIterator.hasNext()) { ProcessedClaim claim = claimIterator.next(); AttributeKey attributeKey = createAttributeKey(claim, saml2); attributeMap.merge( attributeKey, createAttributeBean(attributeKey, claim.getValues()), (v1, v2) -> { v1.getAttributeValues().addAll(claim.getValues()); return v1; }); } AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSamlAttributes(new ArrayList<>(attributeMap.values())); return attrBean; }
public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { // Handle Claims ProcessedClaimCollection retrievedClaims = ClaimsUtils.processClaims(providerParameters); if (retrievedClaims == null) { return null; } Iterator<ProcessedClaim> claimIterator = retrievedClaims.iterator(); if (!claimIterator.hasNext()) { return null; } Map<AttributeKey, AttributeBean> attributeMap = new LinkedHashMap<>(); String tokenType = providerParameters.getTokenRequirements().getTokenType(); boolean saml2 = WSS4JConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType) || WSS4JConstants.SAML2_NS.equals(tokenType); while (claimIterator.hasNext()) { ProcessedClaim claim = claimIterator.next(); AttributeKey attributeKey = createAttributeKey(claim, saml2); attributeMap.merge( attributeKey, createAttributeBean(attributeKey, claim.getValues()), (v1, v2) -> { v1.getAttributeValues().addAll(claim.getValues()); return v1; }); } AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSamlAttributes(new ArrayList<>(attributeMap.values())); return attrBean; }
|| WSS4JConstants.SAML2_NS.equals(tokenType); AttributeStatementBean attrBean = new AttributeStatementBean(); while (claimIterator.hasNext()) { ProcessedClaim claim = claimIterator.next();
|| WSS4JConstants.SAML2_NS.equals(tokenType); AttributeStatementBean attrBean = new AttributeStatementBean(); while (claimIterator.hasNext()) { ProcessedClaim claim = claimIterator.next();
private void createAndSetStatement(SAMLCallback callback) { AuthenticationStatementBean authBean = new AuthenticationStatementBean(); authBean.setAuthenticationMethod("Password"); callback.setAuthenticationStatementData(Collections.singletonList(authBean)); if (attributeStatements != null && !attributeStatements.isEmpty()) { List<AttributeStatementBean> attrStatementBeans = new ArrayList<>(); for (AttributeStatement attrStatement : attributeStatements) { AttributeStatementBean attrStatementBean = new AttributeStatementBean(); List<AttributeBean> attrBeans = new ArrayList<>(); for (Attribute attribute : attrStatement.getAttributes()) { AttributeBean attributeBean = new AttributeBean(); attributeBean.setQualifiedName(attribute.getName()); attributeBean.setNameFormat(attribute.getNameFormat()); List<Object> attributeValues = new ArrayList<>(); for (XMLObject attrVal : attribute.getAttributeValues()) { attributeValues.add(attrVal.getDOM().getTextContent()); } attributeBean.setAttributeValues(attributeValues); attrBeans.add(attributeBean); } attrStatementBean.setSamlAttributes(attrBeans); attrStatementBeans.add(attrStatementBean); } callback.setAttributeStatementData(attrStatementBeans); } }
/** * Get an AttributeStatementBean using the given parameters. */ public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { AttributeStatementBean attrBean = new AttributeStatementBean(); TokenRequirements tokenRequirements = providerParameters.getTokenRequirements(); ReceivedToken actAs = tokenRequirements.getActAs(); try { if (actAs != null) { List<AttributeBean> attributeList = new ArrayList<>(); String tokenType = tokenRequirements.getTokenType(); AttributeBean parameterBean = handleAdditionalParameters(actAs.getToken(), tokenType); if (!parameterBean.getAttributeValues().isEmpty()) { attributeList.add(parameterBean); } attrBean.setSamlAttributes(attributeList); } } catch (WSSecurityException ex) { throw new STSException(ex.getMessage(), ex); } return attrBean; }
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof SAMLCallback) { SAMLCallback callback = (SAMLCallback) callbacks[i]; callback.setSamlVersion(SAMLVersion.VERSION_20); callback.setIssuer("alice"); String subjectName = "uid=auth_client"; SubjectBean subjectBean = new SubjectBean( subjectName, null, SAML2Constants.CONF_SENDER_VOUCHES ); callback.setSubject(subjectBean); AttributeStatementBean attrBean = new AttributeStatementBean(); if (subjectBean != null) { attrBean.setSubject(subjectBean); } AttributeBean attributeBean = new AttributeBean(); attributeBean.setQualifiedName("attribute-role"); attributeBean.setAttributeValues(Collections.singletonList((Object)"authenticated-client")); attrBean.setSamlAttributes(Collections.singletonList(attributeBean)); callback.setAttributeStatementData(Collections.singletonList(attrBean)); } } }
/** * Get an AttributeStatementBean using the given parameters. */ public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { AttributeStatementBean attrBean = new AttributeStatementBean(); TokenRequirements tokenRequirements = providerParameters.getTokenRequirements(); ReceivedToken actAs = tokenRequirements.getActAs(); try { if (actAs != null) { List<AttributeBean> attributeList = new ArrayList<>(); String tokenType = tokenRequirements.getTokenType(); AttributeBean parameterBean = handleAdditionalParameters(actAs.getToken(), tokenType); if (!parameterBean.getAttributeValues().isEmpty()) { attributeList.add(parameterBean); } attrBean.setSamlAttributes(attributeList); } } catch (WSSecurityException ex) { throw new STSException(ex.getMessage(), ex); } return attrBean; }
public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { Principal principal = null; if (providerParameters.getTokenRequirements().getValidateTarget() != null) { ReceivedToken receivedToken = providerParameters.getTokenRequirements().getValidateTarget(); if (receivedToken.getState().equals(STATE.VALID)) { principal = receivedToken.getPrincipal(); } } else { principal = providerParameters.getPrincipal(); } String role = "authenticated-user"; if (principal.getName().contains("CN=Carl Client")) { role = "doubleit-user"; } AttributeBean attributeBean = new AttributeBean(); String tokenType = providerParameters.getTokenRequirements().getTokenType(); if (WSConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType) || WSConstants.SAML2_NS.equals(tokenType)) { attributeBean.setQualifiedName("role"); attributeBean.setNameFormat("http://schemas.xmlsoap.org/ws/2005/05/identity/claims"); } else { attributeBean.setSimpleName("role"); attributeBean.setQualifiedName("http://schemas.xmlsoap.org/ws/2005/05/identity/claims"); } attributeBean.setAttributeValues(Collections.singletonList((Object)role)); AttributeStatementBean attributeStatementBean = new AttributeStatementBean(); attributeStatementBean.setSamlAttributes(Collections.singletonList(attributeBean)); return attributeStatementBean; }
AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean);
Collections.singletonList(authBean)); AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean);
Collections.singletonList(authBean)); AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean);