Search in sources :

Example 1 with StaticSTSProperties

use of org.apache.cxf.sts.StaticSTSProperties in project cas by apereo.

the class CoreWsSecuritySecurityTokenServiceConfiguration method transportSTSProperties.

@RefreshScope
@ConditionalOnMissingBean(name = "transportSTSProperties")
@Bean
public STSPropertiesMBean transportSTSProperties() {
    final WsFederationProperties.SecurityTokenService wsfed = casProperties.getAuthn().getWsfedIdP().getSts();
    final WsFederationProperties.IdentityProvider idp = casProperties.getAuthn().getWsfedIdP().getIdp();
    final StaticSTSProperties s = new StaticSTSProperties();
    s.setIssuer(getClass().getSimpleName());
    s.setRealmParser(new UriRealmParser(realms()));
    s.setSignatureCryptoProperties(CryptoUtils.getSecurityProperties(wsfed.getSigningKeystoreFile(), wsfed.getSigningKeystorePassword()));
    s.setEncryptionCryptoProperties(CryptoUtils.getSecurityProperties(wsfed.getEncryptionKeystoreFile(), wsfed.getEncryptionKeystorePassword()));
    final Relationship rel = new Relationship();
    rel.setType(Relationship.FED_TYPE_IDENTITY);
    rel.setSourceRealm(idp.getRealmName());
    rel.setTargetRealm(idp.getRealmName());
    s.setRelationships(Arrays.asList(rel));
    return s;
}
Also used : WsFederationProperties(org.apereo.cas.configuration.model.support.wsfed.WsFederationProperties) Relationship(org.apache.cxf.sts.token.realm.Relationship) UriRealmParser(org.apereo.cas.support.realm.UriRealmParser) StaticSTSProperties(org.apache.cxf.sts.StaticSTSProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) STSPropertiesMBean(org.apache.cxf.sts.STSPropertiesMBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with StaticSTSProperties

use of org.apache.cxf.sts.StaticSTSProperties in project OpenAM by OpenRock.

the class SoapSTSInstanceModule method getSTSProperties.

/**
     * This method will provide the instance of the STSPropertiesMBean necessary both for the STS proper, and for the
     * CXF interceptor-set which enforces the SecurityPolicy bindings.
     *
     * It should be a singleton because this same instance is shared by all of the token operation instances, as well as
     * by the CXF interceptor-set
     */
@Provides
@Singleton
@Inject
STSPropertiesMBean getSTSProperties(Logger logger) {
    StaticSTSProperties stsProperties = new StaticSTSProperties();
    // KeystoreConfig may be null for a TLS-based SecurityPolicy binding, or for the AM-bare binding.
    if (stsInstanceConfig.getKeystoreConfig() != null) {
        stsProperties.setCallbackHandler(new SoapSTSCallbackHandler(stsInstanceConfig.getKeystoreConfig(), logger));
        Crypto crypto;
        try {
            crypto = CryptoFactory.getInstance(getEncryptionProperties());
        } catch (WSSecurityException e) {
            String message = "Exception caught initializing the CryptoFactory: " + e;
            logger.error(message, e);
            throw new IllegalStateException(message);
        }
        stsProperties.setSignatureCrypto(crypto);
        stsProperties.setEncryptionCrypto(crypto);
        stsProperties.setSignatureUsername(stsInstanceConfig.getKeystoreConfig().getSignatureKeyAlias());
    }
    return stsProperties;
}
Also used : Crypto(org.apache.ws.security.components.crypto.Crypto) SoapSTSCallbackHandler(org.forgerock.openam.sts.soap.SoapSTSCallbackHandler) WSSecurityException(org.apache.ws.security.WSSecurityException) StaticSTSProperties(org.apache.cxf.sts.StaticSTSProperties) Inject(javax.inject.Inject) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)2 Provides (com.google.inject.Provides)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)1 Relationship (org.apache.cxf.sts.token.realm.Relationship)1 WSSecurityException (org.apache.ws.security.WSSecurityException)1 Crypto (org.apache.ws.security.components.crypto.Crypto)1 WsFederationProperties (org.apereo.cas.configuration.model.support.wsfed.WsFederationProperties)1 UriRealmParser (org.apereo.cas.support.realm.UriRealmParser)1 SoapSTSCallbackHandler (org.forgerock.openam.sts.soap.SoapSTSCallbackHandler)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1