Search in sources :

Example 6 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class RegisterPasswordResetAuth method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response, AuthStep as) throws IOException, ServletException {
    HttpSession session = ((HttpServletRequest) request).getSession();
    HashMap<String, Attribute> authParams = (HashMap<String, Attribute>) session.getAttribute(ProxyConstants.AUTH_MECH_PARAMS);
    UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
    RequestHolder reqHolder = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getHolder();
    String urlChain = holder.getUrl().getAuthChain();
    AuthChainType act = holder.getConfig().getAuthChains().get(reqHolder.getAuthChainName());
    AuthMechType amt = act.getAuthMech().get(as.getId());
    AuthController ac = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL));
    AuthInfo au = ac.getAuthInfo();
    Attribute uid = au.getAttribs().get(this.uidAttribute);
    if (uid == null) {
        logger.warn("Attribute : '" + this.uidAttribute + "' does not exist");
        as.setSuccess(false);
    } else {
        ResetUserPasswordOnLogout logoutHandler = new ResetUserPasswordOnLogout(this.workflowName, this.uidAttribute, uid.getValues().get(0));
        LogoutUtil.insertFirstLogoutHandler(request, logoutHandler);
        as.setSuccess(true);
    }
    holder.getConfig().getAuthManager().nextAuth(request, response, session, false);
}
Also used : AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) Attribute(com.tremolosecurity.saml.Attribute) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) AuthMechType(com.tremolosecurity.config.xml.AuthMechType) RequestHolder(com.tremolosecurity.proxy.auth.RequestHolder) AuthController(com.tremolosecurity.proxy.auth.AuthController) HttpServletRequest(javax.servlet.http.HttpServletRequest) UrlHolder(com.tremolosecurity.config.util.UrlHolder) AuthChainType(com.tremolosecurity.config.xml.AuthChainType)

Example 7 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class ResetUserPasswordOnLogout method handleLogout.

@Override
public void handleLogout(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    WFCall wfCall = new WFCall();
    wfCall.setName(this.workflow);
    wfCall.setReason("Logout");
    wfCall.setUidAttributeName(this.uidAttributeName);
    TremoloUser tu = new TremoloUser();
    tu.setUid(this.userID);
    tu.getAttributes().add(new Attribute(this.uidAttributeName, this.userID));
    wfCall.setUser(tu);
    try {
        com.tremolosecurity.provisioning.workflow.ExecuteWorkflow exec = new com.tremolosecurity.provisioning.workflow.ExecuteWorkflow();
        exec.execute(wfCall, GlobalEntries.getGlobalEntries().getConfigManager());
    } catch (Exception e) {
        logger.error("Could not update user", e);
    }
}
Also used : WFCall(com.tremolosecurity.provisioning.service.util.WFCall) TremoloUser(com.tremolosecurity.provisioning.service.util.TremoloUser) Attribute(com.tremolosecurity.saml.Attribute) ServletException(javax.servlet.ServletException)

Example 8 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class TOTPToken method loadAttributeValue.

private String loadAttributeValue(String name, String label, HttpFilterConfig config) throws Exception {
    Attribute attr = config.getAttribute(name);
    if (attr == null) {
        throw new Exception(label + " not found");
    }
    String val = attr.getValues().get(0);
    logger.info(label + ": '" + val + "'");
    return val;
}
Also used : Attribute(com.tremolosecurity.saml.Attribute)

Example 9 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class ScaleToken method doFilter.

@Override
public void doFilter(HttpFilterRequest request, HttpFilterResponse response, HttpFilterChain chain) throws Exception {
    Gson gson = new Gson();
    request.getServletRequest().setAttribute("com.tremolosecurity.unison.proxy.noRedirectOnError", "com.tremolosecurity.unison.proxy.noRedirectOnError");
    if (request.getRequestURI().endsWith("/token/config")) {
        response.setContentType("application/json");
        ScaleJSUtils.addCacheHeaders(response);
        response.getWriter().println(gson.toJson(scaleConfig).trim());
    } else if (request.getMethod().equalsIgnoreCase("GET") && request.getRequestURI().endsWith("/token/user")) {
        AuthInfo userData = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
        ScaleTokenUser stu = new ScaleTokenUser();
        Attribute displayNameAttribute = userData.getAttribs().get(this.scaleConfig.getDisplayNameAttribute());
        if (displayNameAttribute != null) {
            stu.setDisplayName(displayNameAttribute.getValues().get(0));
        } else {
            stu.setDisplayName("Unknown");
        }
        stu.setToken(this.tokenLoader.loadToken(userData, request.getSession()));
        ScaleJSUtils.addCacheHeaders(response);
        response.setContentType("application/json");
        response.getWriter().println(gson.toJson(stu).trim());
    }
}
Also used : ScaleTokenUser(com.tremolosecurity.scalejs.token.data.ScaleTokenUser) AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) Attribute(com.tremolosecurity.saml.Attribute) Gson(com.google.gson.Gson)

Example 10 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class ScaleToken method loadOptionalAttributeValue.

private String loadOptionalAttributeValue(String name, String label, HttpFilterConfig config) throws Exception {
    Attribute attr = config.getAttribute(name);
    if (attr == null) {
        logger.warn(label + " not found");
        return null;
    }
    String val = attr.getValues().get(0);
    logger.info(label + ": '" + val + "'");
    return val;
}
Also used : Attribute(com.tremolosecurity.saml.Attribute)

Aggregations

Attribute (com.tremolosecurity.saml.Attribute)268 LDAPAttribute (com.novell.ldap.LDAPAttribute)90 HashMap (java.util.HashMap)89 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)87 IOException (java.io.IOException)69 ArrayList (java.util.ArrayList)53 LDAPException (com.novell.ldap.LDAPException)51 ServletException (javax.servlet.ServletException)48 AuthInfo (com.tremolosecurity.proxy.auth.AuthInfo)46 AuthController (com.tremolosecurity.proxy.auth.AuthController)45 LDAPEntry (com.novell.ldap.LDAPEntry)43 LDAPSearchResults (com.novell.ldap.LDAPSearchResults)43 HttpSession (javax.servlet.http.HttpSession)40 Gson (com.google.gson.Gson)35 User (com.tremolosecurity.provisioning.core.User)33 HttpServletRequest (javax.servlet.http.HttpServletRequest)33 UrlHolder (com.tremolosecurity.config.util.UrlHolder)31 UnsupportedEncodingException (java.io.UnsupportedEncodingException)30 AuthChainType (com.tremolosecurity.config.xml.AuthChainType)28 HashSet (java.util.HashSet)26