Search in sources :

Example 1 with SASCurrent

use of org.jboss.iiop.csiv2.SASCurrent in project wildfly by wildfly.

the class ElytronSASInitializer method pre_init.

@Override
public void pre_init(ORBInitInfo info) {
    try {
        // create and register the SASCurrent.
        SASCurrent sasCurrent = new SASCurrentImpl();
        info.register_initial_reference("SASCurrent", sasCurrent);
    // the SASCurrent still needs to be initialized. Its initialization is deferred to post_init, as it needs
    // to call resolve_initial_references.
    } catch (InvalidName e) {
        throw IIOPLogger.ROOT_LOGGER.errorRegisteringSASCurrentInitRef(e);
    }
}
Also used : SASCurrent(org.jboss.iiop.csiv2.SASCurrent) InvalidName(org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName)

Example 2 with SASCurrent

use of org.jboss.iiop.csiv2.SASCurrent in project wildfly by wildfly.

the class SASInitializer method pre_init.

@Override
public void pre_init(ORBInitInfo info) {
    try {
        // create and register the SASCurrent.
        SASCurrent sasCurrent = new SASCurrentImpl();
        info.register_initial_reference("SASCurrent", sasCurrent);
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.errorRegisteringSASCurrentInitRef(e);
    }
}
Also used : SASCurrent(org.jboss.iiop.csiv2.SASCurrent)

Example 3 with SASCurrent

use of org.jboss.iiop.csiv2.SASCurrent in project wildfly by wildfly.

the class TrustedIdentityTokenLoginModule method login.

@Override
@SuppressWarnings("unchecked")
public boolean login() throws LoginException {
    // See if shared credentials exist
    if (super.login() == true) {
        // Setup our view of the user
        Object username = sharedState.get("javax.security.auth.login.name");
        if (username instanceof Principal)
            identity = (Principal) username;
        else {
            String name = username.toString();
            try {
                identity = createIdentity(name);
            } catch (Exception e) {
                LoginException le = new LoginException();
                le.initCause(e);
                throw le;
            }
        }
        return true;
    }
    super.loginOk = false;
    if (callbackHandler == null) {
        throw new LoginException();
    }
    SecurityAssociationCallback callback = new SecurityAssociationCallback();
    Callback[] callbacks = { callback };
    final String username;
    try {
        callbackHandler.handle(callbacks);
        username = callback.getPrincipal().getName();
        final Object c = callback.getCredential();
        if (c instanceof SASCurrent) {
            credential = (SASCurrent) c;
        } else {
            return false;
        }
    } catch (IOException e) {
        LoginException le = new LoginException();
        le.initCause(e);
        throw le;
    } catch (UnsupportedCallbackException e) {
        LoginException le = new LoginException();
        le.initCause(e);
        throw le;
    }
    validateCredential(username, credential);
    if (username == null) {
        return false;
    }
    if (identity == null) {
        try {
            identity = createIdentity(username);
        } catch (Exception e) {
            LoginException le = new LoginException();
            le.initCause(e);
            throw le;
        }
    }
    if (getUseFirstPass() == true) {
        // Add the principal to the shared state map
        sharedState.put("javax.security.auth.login.name", identity);
        sharedState.put("javax.security.auth.login.password", credential);
    }
    super.loginOk = true;
    return true;
}
Also used : SASCurrent(org.jboss.iiop.csiv2.SASCurrent) SecurityAssociationCallback(org.jboss.security.auth.callback.SecurityAssociationCallback) Callback(javax.security.auth.callback.Callback) LoginException(javax.security.auth.login.LoginException) IOException(java.io.IOException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) SecurityAssociationCallback(org.jboss.security.auth.callback.SecurityAssociationCallback) Principal(java.security.Principal) LoginException(javax.security.auth.login.LoginException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) IOException(java.io.IOException)

Example 4 with SASCurrent

use of org.jboss.iiop.csiv2.SASCurrent in project wildfly by wildfly.

the class SASClientInitializer method pre_init.

@Override
public void pre_init(ORBInitInfo info) {
    try {
        // create and register the SASCurrent.
        SASCurrent sasCurrent = new SASCurrentImpl();
        info.register_initial_reference("SASCurrent", sasCurrent);
    // the SASCurrent still needs to be initialized. Its initialization is deferred to post_init, as it needs
    // to call resolve_initial_references.
    } catch (InvalidName e) {
        throw IIOPLogger.ROOT_LOGGER.errorRegisteringSASCurrentInitRef(e);
    }
}
Also used : SASCurrent(org.jboss.iiop.csiv2.SASCurrent) InvalidName(org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName)

Aggregations

SASCurrent (org.jboss.iiop.csiv2.SASCurrent)4 InvalidName (org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName)2 IOException (java.io.IOException)1 Principal (java.security.Principal)1 Callback (javax.security.auth.callback.Callback)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 LoginException (javax.security.auth.login.LoginException)1 SecurityAssociationCallback (org.jboss.security.auth.callback.SecurityAssociationCallback)1