本文整理汇总了Java中javax.security.jacc.PolicyContextException类的典型用法代码示例。如果您正苦于以下问题:Java PolicyContextException类的具体用法?Java PolicyContextException怎么用?Java PolicyContextException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolicyContextException类属于javax.security.jacc包,在下文中一共展示了PolicyContextException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPermission
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
@Override
public void addPermission(GrantedPermission permissionDeclaration) {
// todo : do we need to wrap these PolicyConfiguration calls in privileged actions like we do during permission checks?
if ( policyConfiguration == null ) {
policyConfiguration = locatePolicyConfiguration( contextId );
}
for ( String grantedAction : permissionDeclaration.getPermissibleAction().getImpliedActions() ) {
final EJBMethodPermission permission = new EJBMethodPermission(
permissionDeclaration.getEntityName(),
grantedAction,
null, // interfaces
null // arguments
);
log.debugf( "Adding permission [%s] to role [%s]", grantedAction, permissionDeclaration.getRole() );
try {
policyConfiguration.addToRole( permissionDeclaration.getRole(), permission );
}
catch (PolicyContextException pce) {
throw new HibernateException( "policy context exception occurred", pce );
}
}
}
示例2: postSign
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
public void postSign(byte[] signatureValue, List<X509Certificate> signingCertificateChain) {
LOG.debug("postSign");
HttpServletRequest httpServletRequest;
try {
httpServletRequest = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
} catch (PolicyContextException e) {
throw new RuntimeException("JACC error: " + e.getMessage());
}
String signatureValueStr = new String(Hex.encodeHex(signatureValue));
HttpSession session = httpServletRequest.getSession();
session.setAttribute("SignatureValue", signatureValueStr);
session.setAttribute("SigningCertificateChain", signingCertificateChain);
}
示例3: getIdentity
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
@Override
protected Principal getIdentity() {
log.debug("Getting Identity");
HttpServletRequest request = null;
try {
request = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
} catch (PolicyContextException e) {
log.error("Could not load HttpServletRequest", e);
return null;
}
if (request == null) {
return null;
}
return new SimplePrincipal((String) request.getAttribute("UNISON_USER"));
}
示例4: getRequestParameter
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
private static String getRequestParameter(String key) {
if (key == null) {
return null;
}
Object request;
try {
request = PolicyContext.getContext(HttpServletRequest.class.getName());
} catch (PolicyContextException ex) {
logger.log(Level.SEVERE, ex.toString(), ex);
return null;
}
if (request instanceof HttpServletRequest) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String parameter = httpServletRequest.getParameter(key);
logger.log(TRACE, "{0}: {1}", new Object[]{key, parameter});
return parameter;
}
logger.log(TRACE, "HTTP Servlet Request: {0}", request);
return null;
}
示例5: getTimeBasedOTPFromRequest
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
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;
}
示例6: getContextCallbackHandler
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
public CallbackHandler getContextCallbackHandler()
throws PolicyContextException
{
try
{
return (CallbackHandler) AccessController.doPrivileged(exAction);
}
catch(PrivilegedActionException e)
{
Exception ex = e.getException();
if( ex instanceof PolicyContextException )
throw (PolicyContextException) ex;
else
throw new UndeclaredThrowableException(ex);
}
}
示例7: addToRole
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
void addToRole(String roleName, PermissionCollection permissions)
throws PolicyContextException
{
Permissions perms = rolePermissions.get(roleName);
if( perms == null )
{
perms = new Permissions();
rolePermissions.put(roleName, perms);
}
Enumeration<Permission> iter = permissions.elements();
while( iter.hasMoreElements() )
{
Permission p = iter.nextElement();
perms.add(p);
}
}
示例8: JBossPolicyConfiguration
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
protected JBossPolicyConfiguration(String contextID, DelegatingPolicy policy, StateMachine configStateMachine)
throws PolicyContextException
{
this.contextID = contextID;
this.policy = policy;
this.configStateMachine = configStateMachine;
if (contextID == null)
throw PicketBoxMessages.MESSAGES.invalidNullArgument("contextID");
if (policy == null)
throw PicketBoxMessages.MESSAGES.invalidNullArgument("policy");
if (configStateMachine == null)
throw PicketBoxMessages.MESSAGES.invalidNullArgument("configStateMachine");
validateState("getPolicyConfiguration");
PicketBoxLogger.LOGGER.debugJBossPolicyConfigurationConstruction(contextID);
}
示例9: doGet
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("jaccTest", "true");
try {
HttpServletRequest requestFromPolicy = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
if (requestFromPolicy != null) {
response.getWriter().print("Obtained request from context.");
if ("true".equals(requestFromPolicy.getAttribute("jaccTest"))) {
response.getWriter().print("Attribute present in request from context.");
}
if ("true".equals(requestFromPolicy.getParameter("jacc_test"))) {
response.getWriter().print("Request parameter present in request from context.");
}
}
} catch (PolicyContextException e) {
e.printStackTrace(response.getWriter());
}
}
示例10: doGet
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("jaccTest", "true");
try {
if (jaccRequestBean.getRequest() != null) {
response.getWriter().print("Obtained request from context.");
if (jaccRequestBean.hasAttribute()) {
response.getWriter().print("Attribute present in request from context.");
}
if (jaccRequestBean.hasParameter()) {
response.getWriter().print("Request parameter present in request from context.");
}
}
} catch (PolicyContextException e) {
e.printStackTrace(response.getWriter());
}
}
示例11: implies
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
public boolean implies(final ProtectionDomain domain, final Permission permission) {
final String contextID = PolicyContext.getContextID();
if (contextID != null) {
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;
}
示例12: getSubject
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
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");
}
示例13: getContextSubject
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
@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 );
}
}
示例14: getHttpSession
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
/**
* Gives back the current HTTP session using JACC.
*
* @return
*/
public static HttpSession getHttpSession() {
HttpServletRequest httpServletRequest;
try {
httpServletRequest = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
} catch (PolicyContextException e) {
throw new RuntimeException("JACC error: " + e.getMessage());
}
HttpSession httpSession = httpServletRequest.getSession();
return httpSession;
}
示例15: checkNationalRegistrationCertificate
import javax.security.jacc.PolicyContextException; //导入依赖的package包/类
public void checkNationalRegistrationCertificate(List<X509Certificate> certificateChain) throws SecurityException {
LOG.debug("checking national registry certificate...");
HttpServletRequest httpServletRequest;
try {
httpServletRequest = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
} catch (PolicyContextException e) {
throw new RuntimeException("JACC error: " + e.getMessage());
}
HttpSession httpSession = httpServletRequest.getSession();
X509Certificate certificate = certificateChain.get(0);
httpSession.setAttribute("nationalRegistryCertificate", certificate);
}