org.opensaml.common.xml.SAMLConstants Java Examples

The following examples show how to use org.opensaml.common.xml.SAMLConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SAML1ArtifactType0002Builder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the source location used to for the artifacts created by this encoder.
 * 
 * @param requestContext current request context
 * 
 * @return source location used to for the artifacts created by this encoder
 */
protected String getSourceLocation(SAMLMessageContext<RequestAbstractType, Response, NameIdentifier> requestContext) {
    BasicEndpointSelector selector = new BasicEndpointSelector();
    selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME);
    selector.getSupportedIssuerBindings().add(SAMLConstants.SAML1_SOAP11_BINDING_URI);
    selector.setMetadataProvider(requestContext.getMetadataProvider());
    selector.setEntityMetadata(requestContext.getLocalEntityMetadata());
    selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata());

    Endpoint acsEndpoint = selector.selectEndpoint();

    if (acsEndpoint == null) {
        log.error("Unable to select source location for artifact.  No artifact resolution service defined for issuer.");
        return null;
    }

    return acsEndpoint.getLocation();
}
 
Example #2
Source File: StatusCodeSchemaValidator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validates that the status code local name is one of the allowabled values.
 * 
 * @param statusCode the status code to validate
 * 
 * @throws ValidationException thrown if the status code local name is not an allowed value
 */
protected void validateValueContent(StatusCode statusCode) throws ValidationException {
    QName statusValue = statusCode.getValue();

    if (SAMLConstants.SAML10P_NS.equals(statusValue.getNamespaceURI())) {
        if (!(statusValue.equals(StatusCode.SUCCESS) 
                || statusValue.equals(StatusCode.VERSION_MISMATCH)
                || statusValue.equals(StatusCode.REQUESTER) 
                || statusValue.equals(StatusCode.RESPONDER)
                || statusValue.equals(StatusCode.REQUEST_VERSION_TOO_HIGH)
                || statusValue.equals(StatusCode.REQUEST_VERSION_TOO_LOW)
                || statusValue.equals(StatusCode.REQUEST_VERSION_DEPRICATED)
                || statusValue.equals(StatusCode.TOO_MANY_RESPONSES)
                || statusValue.equals(StatusCode.REQUEST_DENIED)
                || statusValue.equals(StatusCode.RESOURCE_NOT_RECOGNIZED))) {
            throw new ValidationException(
                    "Status code value was in the SAML 1 protocol namespace but was not of an allowed value: "
                            + statusValue);
        }
    } else if (SAMLConstants.SAML1_NS.equals(statusValue.getNamespaceURI())) {
        throw new ValidationException(
                "Status code value was in the SAML 1 assertion namespace, no values are allowed in that namespace");
    }
}
 
Example #3
Source File: BaseSAML1MessageDecoder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Populates the peer's entity metadata if a metadata provide is present in the message context. Populates the
 * peer's role descriptor if the entity metadata was available and the role name is present in the message context.
 * 
 * @param messageContext current message context
 * 
 * @throws MessageDecodingException thrown if there is a problem populating the message context
 */
protected void populateRelyingPartyMetadata(SAMLMessageContext messageContext) throws MessageDecodingException {
    MetadataProvider metadataProvider = messageContext.getMetadataProvider();
    try {
        if (metadataProvider != null) {
            EntityDescriptor relyingPartyMD = metadataProvider.getEntityDescriptor(messageContext
                    .getInboundMessageIssuer());
            messageContext.setPeerEntityMetadata(relyingPartyMD);

            QName relyingPartyRole = messageContext.getPeerEntityRole();
            if (relyingPartyMD != null && relyingPartyRole != null) {
                List<RoleDescriptor> roles = relyingPartyMD.getRoleDescriptors(relyingPartyRole,
                        SAMLConstants.SAML11P_NS);
                if (roles != null && roles.size() > 0) {
                    messageContext.setPeerEntityRoleMetadata(roles.get(0));
                }
            }
        }
    } catch (MetadataProviderException e) {
        log.error("Error retrieving metadata for relying party " + messageContext.getInboundMessageIssuer(), e);
        throw new MessageDecodingException("Error retrieving metadata for relying party "
                + messageContext.getInboundMessageIssuer(), e);
    }
}
 
Example #4
Source File: SAMLUtils.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
public static AuthnRequest buildAuthnRequestObject(final String authnId, final String spId, final String idpUrl, final String consumerUrl) {
    // Issuer object
    IssuerBuilder issuerBuilder = new IssuerBuilder();
    Issuer issuer = issuerBuilder.buildObject();
    issuer.setValue(spId);

    // AuthnContextClass
    AuthnContextClassRefBuilder authnContextClassRefBuilder = new AuthnContextClassRefBuilder();
    AuthnContextClassRef authnContextClassRef = authnContextClassRefBuilder.buildObject(
            SAMLConstants.SAML20_NS,
            "AuthnContextClassRef", "saml");
    authnContextClassRef.setAuthnContextClassRef(AuthnContext.PPT_AUTHN_CTX);

    // AuthnContext
    RequestedAuthnContextBuilder requestedAuthnContextBuilder = new RequestedAuthnContextBuilder();
    RequestedAuthnContext requestedAuthnContext = requestedAuthnContextBuilder.buildObject();
    requestedAuthnContext.setComparison(AuthnContextComparisonTypeEnumeration.EXACT);
    requestedAuthnContext.getAuthnContextClassRefs().add(authnContextClassRef);

    // Creation of AuthRequestObject
    AuthnRequestBuilder authRequestBuilder = new AuthnRequestBuilder();
    AuthnRequest authnRequest = authRequestBuilder.buildObject();
    authnRequest.setID(authnId);
    authnRequest.setDestination(idpUrl);
    authnRequest.setVersion(SAMLVersion.VERSION_20);
    authnRequest.setForceAuthn(false);
    authnRequest.setIsPassive(false);
    authnRequest.setIssueInstant(new DateTime());
    authnRequest.setProtocolBinding(SAMLConstants.SAML2_POST_BINDING_URI);
    authnRequest.setAssertionConsumerServiceURL(consumerUrl);
    authnRequest.setProviderName(spId);
    authnRequest.setIssuer(issuer);
    authnRequest.setRequestedAuthnContext(requestedAuthnContext);

    return authnRequest;
}
 
Example #5
Source File: ServiceDescriptionMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    ServiceDescription description = (ServiceDescription) samlObject;

    if (description.getDescription() != null) {
        Attr attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), SAMLConstants.XML_NS,
                ServiceDescription.LANG_ATTRIB_NAME, SAMLConstants.XML_PREFIX);
        attribute.setValue(description.getDescription().getLanguage());
        domElement.setAttributeNodeNS(attribute);
    }
}
 
Example #6
Source File: KeywordsUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    if (attribute.getLocalName().equals(LangBearing.XML_LANG_ATTR_LOCAL_NAME)
            && SAMLConstants.XML_NS.equals(attribute.getNamespaceURI())) {
        Keywords keywords = (Keywords) samlObject;

        keywords.setXMLLang(attribute.getValue());
    }
}
 
Example #7
Source File: KeywordsMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    Keywords words = (Keywords) samlObject;

    if (words.getXMLLang() != null) {
        Attr attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), SAMLConstants.XML_NS,
                LangBearing.XML_LANG_ATTR_LOCAL_NAME, SAMLConstants.XML_PREFIX);
        attribute.setValue(words.getXMLLang());
        domElement.setAttributeNodeNS(attribute);
    }
}
 
Example #8
Source File: LocalizedNameMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    LocalizedName name = (LocalizedName) samlObject;

    if (name.getName() != null) {
        Attr attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), SAMLConstants.XML_NS,
                LangBearing.XML_LANG_ATTR_LOCAL_NAME, SAMLConstants.XML_PREFIX);
        attribute.setValue(name.getName().getLanguage());
        domElement.setAttributeNodeNS(attribute);
    }
}
 
Example #9
Source File: ConditionsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public OneTimeUse getOneTimeUse() {
    QName conditionQName = new QName(SAMLConstants.SAML20_NS, OneTimeUse.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20_PREFIX);
    List<OneTimeUse> list = (List<OneTimeUse>) conditions.subList(conditionQName);
    if (list == null || list.size() == 0) {
        return null;
    } else {
        return list.get(0);
    }
}
 
Example #10
Source File: RequestAuthenticatedBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public RequestAuthenticated buildObject() {
    return buildObject(SAMLConstants.SAML20ECP_NS, RequestAuthenticated.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20ECP_PREFIX);
}
 
Example #11
Source File: AuthnContextDeclBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public AuthnContextDecl buildObject() {
    return buildObject(SAMLConstants.SAML20_NS, AuthnContextDecl.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20_PREFIX);
}
 
Example #12
Source File: AudienceRestrictionBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public AudienceRestriction buildObject() {
    return buildObject(SAMLConstants.SAML20_NS, AudienceRestriction.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20_PREFIX);
}
 
Example #13
Source File: HTTPSOAP11Encoder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public String getBindingURI() {
    return SAMLConstants.SAML1_SOAP11_BINDING_URI;
}
 
Example #14
Source File: HTTPSOAP11Encoder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public String getBindingURI() {
    return SAMLConstants.SAML2_SOAP11_BINDING_URI;
}
 
Example #15
Source File: NameIDMappingResponseBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public NameIDMappingResponse buildObject() {
    return buildObject(SAMLConstants.SAML20P_NS, NameIDMappingResponse.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20P_PREFIX);
}
 
Example #16
Source File: TelephoneNumberBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public TelephoneNumber buildObject() {
    return buildObject(SAMLConstants.SAML20MD_NS, TelephoneNumber.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
}
 
Example #17
Source File: SessionKeyBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public SessionKey buildObject() {
    return buildObject(SAMLConstants.SAMLEC_GSS_NS, SessionKey.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAMLEC_GSS_PREFIX);
}
 
Example #18
Source File: EncTypeBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public EncType buildObject() {
    return buildObject(SAMLConstants.SAMLEC_GSS_NS, EncType.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAMLEC_GSS_PREFIX);
}
 
Example #19
Source File: GeneratedKeyBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public GeneratedKey buildObject() {
    return buildObject(SAMLConstants.SAMLEC_GSS_NS, GeneratedKey.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAMLEC_GSS_PREFIX);
}
 
Example #20
Source File: MetadataGenerator.java    From MaxKey with Apache License 2.0 4 votes vote down vote up
public ManageNameIDService getManageNameIDService(String url){
 ManageNameIDService manageNameIDService=new ManageNameIDServiceBuilder().buildObject();
 manageNameIDService.setLocation(url);
 manageNameIDService.setBinding(SAMLConstants.SAML2_POST_BINDING_URI);
 return manageNameIDService;
}
 
Example #21
Source File: AssertionBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Assertion buildObject() {
    return buildObject(SAMLConstants.SAML20_NS, Assertion.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
}
 
Example #22
Source File: AssertionURIRefBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public AssertionURIRef buildObject() {
    return buildObject(SAMLConstants.SAML20_NS, AssertionURIRef.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20_PREFIX);
}
 
Example #23
Source File: EvidenceBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Evidence buildObject() {
    return buildObject(SAMLConstants.SAML1_NS, Evidence.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
}
 
Example #24
Source File: StatusDetailBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public StatusDetail buildObject() {
    return buildObject(SAMLConstants.SAML10P_NS, StatusDetail.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
}
 
Example #25
Source File: PDPDescriptorBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public PDPDescriptor buildObject() {
    return buildObject(SAMLConstants.SAML20MD_NS, PDPDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
}
 
Example #26
Source File: OrganizationNameBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public OrganizationName buildObject() {
    return buildObject(SAMLConstants.SAML20MD_NS, OrganizationName.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
}
 
Example #27
Source File: SubjectConfirmationDataBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public SubjectConfirmationData buildObject() {
    return buildObject(SAMLConstants.SAML20_NS, SubjectConfirmationData.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20_PREFIX);
}
 
Example #28
Source File: SubjectConfirmationBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public SubjectConfirmation buildObject() {
    return buildObject(SAMLConstants.SAML1_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
}
 
Example #29
Source File: SingleLogoutServiceBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public SingleLogoutService buildObject() {
    return buildObject(SAMLConstants.SAML20MD_NS, SingleLogoutService.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
}
 
Example #30
Source File: NameIDPolicyBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public NameIDPolicy buildObject() {
    return buildObject(SAMLConstants.SAML20P_NS, NameIDPolicy.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20P_PREFIX);
}