Search in sources :

Example 11 with KeyProvider

use of com.sun.identity.saml.xmlsig.KeyProvider in project OpenAM by OpenRock.

the class SPSSOFederate method signAuthnRequest.

/**
     * Sign an authentication request.
     *
     * @param certAlias the certificate alias
     * @param authnRequest the authentication request to sign
     * @throws SAML2Exception the signed authentication request
     */
public static void signAuthnRequest(final String certAlias, final AuthnRequest authnRequest) throws SAML2Exception {
    KeyProvider kp = KeyUtil.getKeyProviderInstance();
    if (kp == null) {
        SAML2Utils.debug.error("SPSSOFederate:signAuthnRequest: " + "Unable to get a key provider instance.");
        throw new SAML2Exception(SAML2Utils.bundle.getString("nullKeyProvider"));
    }
    authnRequest.sign(kp.getPrivateKey(certAlias), kp.getX509Certificate(certAlias));
}
Also used : KeyProvider(com.sun.identity.saml.xmlsig.KeyProvider) SAML2Exception(com.sun.identity.saml2.common.SAML2Exception)

Example 12 with KeyProvider

use of com.sun.identity.saml.xmlsig.KeyProvider in project OpenAM by OpenRock.

the class SPSSOFederate method signQueryString.

/**
     * Signs the query string.
     *
     * @param queryString the query string
     * @param certAlias the certificate alias
     * @return the signed query string
     * @throws SAML2Exception
     */
public static String signQueryString(final String queryString, final String certAlias) throws SAML2Exception {
    if (SAML2Utils.debug.messageEnabled()) {
        SAML2Utils.debug.message("SPSSOFederate:queryString:" + queryString);
        SAML2Utils.debug.message("SPSSOFederate: certAlias :" + certAlias);
    }
    KeyProvider kp = KeyUtil.getKeyProviderInstance();
    PrivateKey privateKey = kp.getPrivateKey(certAlias);
    return QuerySignatureUtil.sign(queryString, privateKey);
}
Also used : KeyProvider(com.sun.identity.saml.xmlsig.KeyProvider) PrivateKey(java.security.PrivateKey)

Aggregations

KeyProvider (com.sun.identity.saml.xmlsig.KeyProvider)12 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)10 PrivateKey (java.security.PrivateKey)6 X509Certificate (java.security.cert.X509Certificate)4 Date (java.util.Date)3 Issuer (com.sun.identity.saml2.assertion.Issuer)2 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)2 Artifact (com.sun.identity.saml2.protocol.Artifact)2 ArtifactResolve (com.sun.identity.saml2.protocol.ArtifactResolve)2 ArtifactResponse (com.sun.identity.saml2.protocol.ArtifactResponse)2 Response (com.sun.identity.saml2.protocol.Response)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 SOAPConnection (javax.xml.soap.SOAPConnection)2 SOAPException (javax.xml.soap.SOAPException)2 SOAPMessage (javax.xml.soap.SOAPMessage)2 PolicyException (com.sun.identity.policy.PolicyException)1 ValidValues (com.sun.identity.policy.ValidValues)1 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)1 XACMLAuthzDecisionQueryConfigElement (com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement)1 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)1