Search in sources :

Example 1 with Entry

use of org.wildfly.security.authz.Attributes.Entry in project wildfly by wildfly.

the class AttributePrintingServlet method doGet.

/**
 * Writes plain-text response with all of the current identities attributes.
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("text/plain");
    final PrintWriter writer = resp.getWriter();
    SecurityDomain securityDomain = SecurityDomain.getCurrent();
    SecurityIdentity securityIdentity = securityDomain.getCurrentSecurityIdentity();
    Attributes attributes = securityIdentity.getAttributes();
    for (Entry currentAttribute : attributes.entries()) {
        writer.print(currentAttribute.getKey());
        writer.print("=");
        for (int i = 0; i < currentAttribute.size(); i++) {
            writer.print(currentAttribute.get(i));
            if (i < currentAttribute.size()) {
                writer.print(",");
            }
        }
        writer.println();
    }
    writer.close();
}
Also used : SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) Entry(org.wildfly.security.authz.Attributes.Entry) Attributes(org.wildfly.security.authz.Attributes) HttpConstraint(javax.servlet.annotation.HttpConstraint) PrintWriter(java.io.PrintWriter) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain)

Aggregations

PrintWriter (java.io.PrintWriter)1 HttpConstraint (javax.servlet.annotation.HttpConstraint)1 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)1 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)1 Attributes (org.wildfly.security.authz.Attributes)1 Entry (org.wildfly.security.authz.Attributes.Entry)1