/** * Return the security context for this bean factory. If a security manager * is set, interaction with the user code will be executed using the privileged * of the security context returned by this method. * @see AccessController#getContext() */ protected AccessControlContext getAccessControlContext() { return AccessController.getContext(); }
@Override public AccessControlContext getAccessControlContext() { return (this.acc != null ? this.acc : AccessController.getContext()); }
/** * Return the security context for this bean factory. If a security manager * is set, interaction with the user code will be executed using the privileged * of the security context returned by this method. * @see AccessController#getContext() */ protected AccessControlContext getAccessControlContext() { return AccessController.getContext(); }
@Override public AccessControlContext getAccessControlContext() { return (this.acc != null ? this.acc : AccessController.getContext()); }
public ServiceLoaderSupplier(final Class<E> service, final ClassLoader classLoader) { this.service = service; this.classLoader = classLoader; this.acc = AccessController.getContext() ; }
/** * Construct a new instance of {@code PrivilegedServerMechanismFactory} using the current {@link AccessControlContext} for * calls to the wrapped factory * * @param delegate the {@link HttpServerAuthenticationMechanismFactory} to delegate to. */ public PrivilegedServerMechanismFactory(final HttpServerAuthenticationMechanismFactory delegate) { this(delegate, AccessController.getContext()); }
/** * Construct a new instance. * * @param delegate the delegate SASL client factory */ public PrivilegedSaslClientFactory(final SaslClientFactory delegate) { this(delegate, AccessController.getContext()); }
/** * Construct a new instance. * * @param delegate the delegate SASL server factory */ public PrivilegedSaslServerFactory(final SaslServerFactory delegate) { this(delegate, AccessController.getContext()); }
/** * Delegate the creation of the access control context to the * {@link #setSecurityContextProvider SecurityContextProvider}. */ @Override public AccessControlContext getAccessControlContext() { return (this.securityContextProvider != null ? this.securityContextProvider.getAccessControlContext() : AccessController.getContext()); }
@Override public Subject run() { return Subject.getSubject(AccessController.getContext()); } });
@Override protected ReqContext initialValue() { return new ReqContext(AccessController.getContext()); } };
private void handleCallback(OAuthBearerTokenCallback callback) throws IOException { if (callback.token() != null) throw new IllegalArgumentException("Callback had a token already"); Subject subject = Subject.getSubject(AccessController.getContext()); Set<OAuthBearerToken> privateCredentials = subject != null ? subject.getPrivateCredentials(OAuthBearerToken.class) : Collections.emptySet(); if (privateCredentials.size() != 1) throw new IOException( String.format("Unable to find OAuth Bearer token in Subject's private credentials (size=%d)", privateCredentials.size())); callback.token(privateCredentials.iterator().next()); }
/** * Delegate the creation of the access control context to the * {@link #setSecurityContextProvider SecurityContextProvider}. */ @Override public AccessControlContext getAccessControlContext() { return (this.securityContextProvider != null ? this.securityContextProvider.getAccessControlContext() : AccessController.getContext()); }
/** * Perform a permission check. * * @param perm the permission to check * @throws SecurityException if the check fails */ public void checkPermission(final Permission perm) throws SecurityException { checkPermission(perm, AccessController.getContext()); }
CommandCredentialSource(final Builder builder) throws GeneralSecurityException { builderProcessor = builder.builderProcessor; this.passwordFactory = builder.passwordFactoryFactory.create(); context = AccessController.getContext(); outputCharset = builder.outputCharset; }
/** * Create a new configuration which is the same as this configuration, but which captures the caller's access * control context to be used in authentication decisions. * * @return the new configuration */ public AuthenticationConfiguration withCapturedAccessControlContext() { return new AuthenticationConfiguration(this, SET_ACCESS_CTXT, getContext()); }
private static String getCurrentSubjectName() { final AccessControlContext acc = AccessController.getContext(); return AccessController.doPrivileged(new PrivilegedAction<String>() { @Override public String run() { Subject subject = Subject.getSubject(acc); if (subject == null) { return null; } Set<Principal> principals = subject.getPrincipals(); if (principals == null) { return null; } for (Principal p : principals) { return p.getName(); } return null; } }); }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (!configured()) throw new IllegalStateException("Callback handler not configured"); for (Callback callback : callbacks) { if (callback instanceof OAuthBearerTokenCallback) handleCallback((OAuthBearerTokenCallback) callback); else if (callback instanceof SaslExtensionsCallback) handleCallback((SaslExtensionsCallback) callback, Subject.getSubject(AccessController.getContext())); else throw new UnsupportedCallbackException(callback); } }
public void init() { AccessControlContext acc = AccessController.getContext(); Subject subject = Subject.getSubject(acc); if (subject == null) { return; } setNameFromPrincipal(subject.getPrincipals()); }
@GetMapping("/username") public String username() { Subject subject = Subject.getSubject(AccessController.getContext()); return subject.getPrincipals().iterator().next().getName(); } }