javax.security.jacc.PolicyContext Java Examples
The following examples show how to use
javax.security.jacc.PolicyContext.
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: AuthorizationPreFilter.java From piranha with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { WebApplication context = (WebApplication) request.getServletContext(); PolicyContext.setContextID(context.getServletContextId()); if (!securityManager.isRequestSecurityAsRequired(request, response)) { response.setStatus(SC_FORBIDDEN); return; } localServletRequest.set(request); try { chain.doFilter(request, response); } finally { localServletRequest.remove(); } }
Example #2
Source File: BasicJaccProvider.java From tomee with Apache License 2.0 | 6 votes |
public boolean implies(final ProtectionDomain domain, final Permission permission) { final String contextID = PolicyContext.getContextID(); if (contextID != null && JACC_PERMISSIONS.contains(permission.getClass())) { try { final BasicPolicyConfiguration configuration = configurations.get(contextID); if (configuration == null || !configuration.inService()) { return false; } return configuration.implies(domain, permission); } catch (final PolicyContextException e) { // no-op } } return systemPolicy != null ? systemPolicy.implies(domain, permission) : false; }
Example #3
Source File: JBossTimeBasedOTPLoginModule.java From lams with GNU General Public License v2.0 | 6 votes |
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 #4
Source File: ServiceServlet.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
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 #5
Source File: JavaSecurityManagers.java From tomee with Apache License 2.0 | 5 votes |
public static void setContextID(final String moduleID) { if (System.getSecurityManager() == null) { PolicyContext.setContextID(moduleID); } else { AccessController.doPrivileged(new PrivilegedAction<String>() { @Override public String run() { PolicyContext.setContextID(moduleID); return null; } }); } }
Example #6
Source File: WebXACMLPolicyModuleDelegate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Process the web request * @param request * @param callerRoles * @return */ private int process(HttpServletRequest request, RoleGroup callerRoles ) { Principal userP = request.getUserPrincipal(); if(userP == null) throw PicketBoxMessages.MESSAGES.invalidNullProperty("userPrincipal"); int result = AuthorizationContext.DENY; WebXACMLUtil util = new WebXACMLUtil(); try { RequestContext requestCtx = util.createXACMLRequest(request,callerRoles); if(this.policyContextID == null) this.policyContextID = PolicyContext.getContextID(); PolicyDecisionPoint pdp = util.getPDP(this.policyRegistration, this.policyContextID); ResponseContext response = pdp.evaluate(requestCtx); result = response.getDecision() == XACMLConstants.DECISION_PERMIT ? AuthorizationContext.PERMIT : AuthorizationContext.DENY; } catch(Exception e) { PicketBoxLogger.LOGGER.debugIgnoredException(e); result = AuthorizationContext.DENY; } return result; }
Example #7
Source File: StandardJaccServiceImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@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 #8
Source File: ServiceEJB.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
@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 #9
Source File: SubjectEndpoint.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
@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 #10
Source File: SecurityActions.java From lams with GNU General Public License v2.0 | 4 votes |
public CallbackHandler run() throws Exception { return (CallbackHandler) PolicyContext.getContext(SecurityConstants.CALLBACK_HANDLER_KEY); }
Example #11
Source File: SecurityActions.java From lams with GNU General Public License v2.0 | 4 votes |
public CallbackHandler getContextCallbackHandler() throws PolicyContextException { return (CallbackHandler) PolicyContext.getContext(SecurityConstants.CALLBACK_HANDLER_KEY); }
Example #12
Source File: StandardJaccServiceImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public String run() { String previousID = PolicyContext.getContextID(); PolicyContext.setContextID( contextId ); return previousID; }
Example #13
Source File: JASPIServerAuthenticationManager.java From lams with GNU General Public License v2.0 | 4 votes |
public boolean isValid(MessageInfo requestMessage,Subject clientSubject, String layer, CallbackHandler handler) { return this.isValid(requestMessage, clientSubject, layer, PolicyContext.getContextID(), handler); }
Example #14
Source File: SubjectActions.java From lams with GNU General Public License v2.0 | 4 votes |
public Subject run() throws PolicyContextException { return (Subject) PolicyContext.getContext(SecurityConstants.SUBJECT_CONTEXT_KEY); }
Example #15
Source File: JACCPermissions.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public Object run() throws Exception { return (Subject) PolicyContext.getContext( SUBJECT_CONTEXT_KEY ); }
Example #16
Source File: JACCPermissions.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public Subject getContextSubject() throws PolicyContextException { return (Subject) PolicyContext.getContext( SUBJECT_CONTEXT_KEY ); }
Example #17
Source File: JACCPermissions.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public Object run() { String previousID = PolicyContext.getContextID(); PolicyContext.setContextID( contextID ); return previousID; }