Search in sources :

Example 1 with TokenSigningKeyInfoElement

use of com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement in project OpenAM by OpenRock.

the class WSFederationMetaSecurityUtils method updateKeyDescriptor.

private static void updateKeyDescriptor(FederationElement desp, TokenSigningKeyInfoElement newKey) {
    // NOTE : we only support one signing and one encryption key right now 
    // the code need to be change if we need to support multiple signing
    // and/or encryption keys in one entity
    List objList = desp.getAny();
    for (Iterator iter = objList.iterator(); iter.hasNext(); ) {
        Object o = iter.next();
        if (o instanceof TokenSigningKeyInfoElement) {
            iter.remove();
        }
    }
    desp.getAny().add(0, newKey);
}
Also used : TokenSigningKeyInfoElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement) Iterator(java.util.Iterator) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Example 2 with TokenSigningKeyInfoElement

use of com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement in project OpenAM by OpenRock.

the class WSFederationMetaSecurityUtils method updateProviderKeyInfo.

/**
     * Updates signing or encryption key info for SP or IDP.
     * This will update both signing/encryption alias on extended metadata and
     * certificates in standard metadata.
     * @param realm Realm the entity resides.
     * @param entityID ID of the entity to be updated.
     * @param certAlias Alias of the certificate to be set to the entity. If
     *        null, will remove existing key information from the SP or IDP.
     * @param isIDP true if this is for IDP signing/encryption alias, false
     *        if this is for SP signing/encryption alias
     * @throws WSFederationMetaException if failed to update the certificate 
     *        alias for the entity.
     */
public static void updateProviderKeyInfo(String realm, String entityID, String certAlias, boolean isIDP) throws WSFederationMetaException {
    WSFederationMetaManager metaManager = new WSFederationMetaManager();
    FederationConfigElement config = metaManager.getEntityConfig(realm, entityID);
    if (!config.isHosted()) {
        String[] args = { entityID, realm };
        throw new WSFederationMetaException("entityNotHosted", args);
    }
    FederationElement desp = metaManager.getEntityDescriptor(realm, entityID);
    if (isIDP) {
        IDPSSOConfigElement idpConfig = metaManager.getIDPSSOConfig(realm, entityID);
        if ((idpConfig == null) || (desp == null)) {
            String[] args = { entityID, realm };
            throw new WSFederationMetaException("entityNotIDP", args);
        }
        // update standard metadata
        if ((certAlias == null) || (certAlias.length() == 0)) {
            // remove key info
            removeKeyDescriptor(desp);
            setExtendedAttributeValue(idpConfig, SAML2Constants.SIGNING_CERT_ALIAS, null);
        } else {
            TokenSigningKeyInfoElement kde = getKeyDescriptor(certAlias);
            updateKeyDescriptor(desp, kde);
            // update extended metadata
            Set value = new HashSet();
            value.add(certAlias);
            setExtendedAttributeValue(idpConfig, SAML2Constants.SIGNING_CERT_ALIAS, value);
        }
    } else {
        SPSSOConfigElement spConfig = metaManager.getSPSSOConfig(realm, entityID);
        if ((spConfig == null) || (desp == null)) {
            String[] args = { entityID, realm };
            throw new WSFederationMetaException("entityNotSP", args);
        }
        // update standard metadata
        if ((certAlias == null) || (certAlias.length() == 0)) {
            // remove key info
            removeKeyDescriptor(desp);
            setExtendedAttributeValue(spConfig, SAML2Constants.SIGNING_CERT_ALIAS, null);
        } else {
            TokenSigningKeyInfoElement kde = getKeyDescriptor(certAlias);
            updateKeyDescriptor(desp, kde);
            // update extended metadata
            Set value = new HashSet();
            value.add(certAlias);
            setExtendedAttributeValue(spConfig, SAML2Constants.SIGNING_CERT_ALIAS, value);
        }
    }
    metaManager.setFederation(realm, desp);
    metaManager.setEntityConfig(realm, config);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) TokenSigningKeyInfoElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement) SPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) IDPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) HashSet(java.util.HashSet)

Example 3 with TokenSigningKeyInfoElement

use of com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement in project OpenAM by OpenRock.

the class CreateWSFedMetaDataTemplate method addWSFedIdentityProviderTemplate.

private static void addWSFedIdentityProviderTemplate(String entityId, com.sun.identity.wsfederation.jaxb.wsfederation.ObjectFactory objFactory, FederationElement fed, Map mapParams, String url) throws JAXBException, CertificateEncodingException {
    if (url == null) {
        url = getHostURL();
    }
    String idpAlias = (String) mapParams.get(MetaTemplateParameters.P_IDP);
    String idpSCertAlias = (String) mapParams.get(MetaTemplateParameters.P_IDP_S_CERT);
    String maStr = buildMetaAliasInURI(idpAlias);
    if ((idpSCertAlias != null) && idpSCertAlias.length() > 0) {
        com.sun.identity.wsfederation.jaxb.wsse.ObjectFactory secextObjFactory = new com.sun.identity.wsfederation.jaxb.wsse.ObjectFactory();
        com.sun.identity.wsfederation.jaxb.xmlsig.ObjectFactory dsObjectFactory = new com.sun.identity.wsfederation.jaxb.xmlsig.ObjectFactory();
        TokenSigningKeyInfoElement tski = objFactory.createTokenSigningKeyInfoElement();
        SecurityTokenReferenceElement str = secextObjFactory.createSecurityTokenReferenceElement();
        X509DataElement x509Data = dsObjectFactory.createX509DataElement();
        X509Certificate x509Cert = dsObjectFactory.createX509DataTypeX509Certificate();
        x509Cert.setValue(KeyUtil.getKeyProviderInstance().getX509Certificate(idpSCertAlias).getEncoded());
        x509Data.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(x509Cert);
        str.getAny().add(x509Data);
        tski.setSecurityTokenReference(str);
        fed.getAny().add(tski);
    }
    TokenIssuerNameElement tin = objFactory.createTokenIssuerNameElement();
    tin.setValue(entityId);
    fed.getAny().add(tin);
    TokenIssuerEndpointElement tie = objFactory.createTokenIssuerEndpointElement();
    com.sun.identity.wsfederation.jaxb.wsaddr.ObjectFactory addrObjFactory = new com.sun.identity.wsfederation.jaxb.wsaddr.ObjectFactory();
    AttributedURIType auri = addrObjFactory.createAttributedURIType();
    auri.setValue(url + "/WSFederationServlet" + maStr);
    tie.setAddress(auri);
    fed.getAny().add(tie);
    TokenTypesOfferedElement tto = objFactory.createTokenTypesOfferedElement();
    TokenType tt = objFactory.createTokenType();
    tt.setUri(WSFederationConstants.URN_OASIS_NAMES_TC_SAML_11);
    tto.getTokenType().add(tt);
    fed.getAny().add(tto);
    UriNamedClaimTypesOfferedElement uncto = objFactory.createUriNamedClaimTypesOfferedElement();
    ClaimType ct = objFactory.createClaimType();
    ct.setUri(WSFederationConstants.NAMED_CLAIM_TYPES[WSFederationConstants.NAMED_CLAIM_UPN]);
    DisplayNameType dnt = objFactory.createDisplayNameType();
    dnt.setValue(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_UPN]);
    ct.setDisplayName(dnt);
    uncto.getClaimType().add(ct);
    fed.getAny().add(uncto);
}
Also used : TokenTypesOfferedElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenTypesOfferedElement) AttributedURIType(com.sun.identity.wsfederation.jaxb.wsaddr.AttributedURIType) TokenIssuerEndpointElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement) ClaimType(com.sun.identity.wsfederation.jaxb.wsfederation.ClaimType) TokenType(com.sun.identity.wsfederation.jaxb.wsfederation.TokenType) X509DataElement(com.sun.identity.wsfederation.jaxb.xmlsig.X509DataElement) TokenIssuerNameElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerNameElement) UriNamedClaimTypesOfferedElement(com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement) SecurityTokenReferenceElement(com.sun.identity.wsfederation.jaxb.wsse.SecurityTokenReferenceElement) DisplayNameType(com.sun.identity.wsfederation.jaxb.wsfederation.DisplayNameType) X509Certificate(com.sun.identity.wsfederation.jaxb.xmlsig.X509DataType.X509Certificate) TokenSigningKeyInfoElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement)

Aggregations

TokenSigningKeyInfoElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement)3 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)1 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)1 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)1 AttributedURIType (com.sun.identity.wsfederation.jaxb.wsaddr.AttributedURIType)1 ClaimType (com.sun.identity.wsfederation.jaxb.wsfederation.ClaimType)1 DisplayNameType (com.sun.identity.wsfederation.jaxb.wsfederation.DisplayNameType)1 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)1 TokenIssuerEndpointElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement)1 TokenIssuerNameElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerNameElement)1 TokenType (com.sun.identity.wsfederation.jaxb.wsfederation.TokenType)1 TokenTypesOfferedElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenTypesOfferedElement)1 UriNamedClaimTypesOfferedElement (com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement)1 SecurityTokenReferenceElement (com.sun.identity.wsfederation.jaxb.wsse.SecurityTokenReferenceElement)1 X509DataElement (com.sun.identity.wsfederation.jaxb.xmlsig.X509DataElement)1 X509Certificate (com.sun.identity.wsfederation.jaxb.xmlsig.X509DataType.X509Certificate)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1