Java Code Examples for javax.security.jacc.PolicyContext#getContext()

The following examples show how to use javax.security.jacc.PolicyContext#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JBossTimeBasedOTPLoginModule.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private String getTimeBasedOTPFromRequest()
{
   String totp = null;

   //This is JBoss AS specific mechanism 
   String WEB_REQUEST_KEY = "javax.servlet.http.HttpServletRequest";

   try
   {
      HttpServletRequest request = (HttpServletRequest) PolicyContext.getContext(WEB_REQUEST_KEY);
      totp = request.getParameter( TOTP );
   }
   catch (PolicyContextException e)
   {
      PicketBoxLogger.LOGGER.debugErrorGettingRequestFromPolicyContext(e);
   }
   return totp; 
}
 
Example 2
Source File: ServiceServlet.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
private String getSubject(HttpServletResponse response) throws IOException {
    try {
        Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");
        Set<? extends Principal> principalSet = subject.getPrincipals(JsonWebToken.class);
        if(principalSet.size() > 0) {
            return "subject.getPrincipals(JsonWebToken.class) ok";
        }
        response.sendError(500, "subject.getPrincipals(JsonWebToken.class) == 0");
    }
    catch (PolicyContextException e) {
        e.printStackTrace();
        response.sendError(500, e.getMessage());
    }
    throw new IllegalStateException("subject.getPrincipals(JsonWebToken.class) == 0");
}
 
Example 3
Source File: SubjectEndpoint.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/getSubjectClass")
@RolesAllowed("Tester")
public String getSubjectClass(@Context SecurityContext sec) throws Exception {
    Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");
    Set<? extends Principal> principalSet = subject.getPrincipals(JsonWebToken.class);
    if (principalSet.size() > 0) {
        return "subject.getPrincipals(JWTPrincipal.class) ok";
    }
    throw new IllegalStateException("subject.getPrincipals(JWTPrincipal.class) == 0");
}
 
Example 4
Source File: ServiceEJB.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
@RolesAllowed("Tester")
public String getSubjectClass() throws Exception {
    Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");
    System.out.printf("ServiceEJB.getSubjectClass, subject=%s\n", subject);
    Set<? extends Principal> principalSet = subject.getPrincipals(JsonWebToken.class);
    if (principalSet.size() > 0) {
        return "subject.getPrincipals(JsonWebToken.class) ok";
    }
    throw new IllegalStateException("subject.getPrincipals(JsonWebToken.class) == 0");
}
 
Example 5
Source File: StandardJaccServiceImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Subject getContextSubject() {
	try {
		return (Subject) PolicyContext.getContext( SUBJECT_CONTEXT_KEY );
	}
	catch (PolicyContextException e) {
		throw new HibernateException( "Unable to access JACC PolicyContext in order to locate calling Subject", e );
	}
}
 
Example 6
Source File: SecurityActions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public CallbackHandler run() throws Exception
{
   return (CallbackHandler) PolicyContext.getContext(SecurityConstants.CALLBACK_HANDLER_KEY);
}
 
Example 7
Source File: SecurityActions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public CallbackHandler getContextCallbackHandler()
   throws PolicyContextException
{
   return (CallbackHandler) PolicyContext.getContext(SecurityConstants.CALLBACK_HANDLER_KEY);
}
 
Example 8
Source File: SubjectActions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Subject run() throws PolicyContextException
{
   return (Subject) PolicyContext.getContext(SecurityConstants.SUBJECT_CONTEXT_KEY);  
}
 
Example 9
Source File: JACCPermissions.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Object run() throws Exception {
	return (Subject) PolicyContext.getContext( SUBJECT_CONTEXT_KEY );
}
 
Example 10
Source File: JACCPermissions.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Subject getContextSubject() throws PolicyContextException {
	return (Subject) PolicyContext.getContext( SUBJECT_CONTEXT_KEY );
}