private boolean runAsPrincipalExists(final SecurityDomain securityDomain, final String runAsPrincipal) throws RealmUnavailableException { RealmIdentity realmIdentity = null; try { realmIdentity = securityDomain.getIdentity(runAsPrincipal); return realmIdentity.exists(); } finally { if (realmIdentity != null) { realmIdentity.dispose(); } } } }
/** * Look up a {@link RealmIdentity} by name by wrapping the name in a {@link NamePrincipal} and calling {@link #getIdentity(Principal)}. * The returned identity must be {@linkplain RealmIdentity#dispose() disposed}. * * @param name the name to map (must not be {@code null}) * @return the identity for the name (not {@code null}, may be non-existent) * @throws RealmUnavailableException if the realm is not able to perform the mapping * @throws IllegalArgumentException if the name is not valid * @throws SecurityException if the caller is not authorized to perform the operation */ public RealmIdentity getIdentity(String name) throws RealmUnavailableException { Assert.checkNotNullParam("name", name); return getIdentity(new NamePrincipal(name)); }
static boolean runAsPrincipalExists(final SecurityDomain securityDomain, final String runAsPrincipal) { RealmIdentity realmIdentity = null; try { realmIdentity = securityDomain.getIdentity(runAsPrincipal); return realmIdentity.exists(); } catch (RealmUnavailableException e) { // TODO Throw a replcement exception throw new IllegalStateException(String.format("Unable to obtain identity for name %s", runAsPrincipal), e); //throw UndertowLogger.ROOT_LOGGER.unableToObtainIdentity(runAsPrincipal, e); } finally { if (realmIdentity != null) { realmIdentity.dispose(); } } }
/** * Look up a {@link RealmIdentity} by name by wrapping the name in a {@link NamePrincipal} and calling {@link #getIdentity(Principal)}. * The returned identity must be {@linkplain RealmIdentity#dispose() disposed}. * * @param name the name to map (must not be {@code null}) * @return the identity for the name (not {@code null}, may be non-existent) * @throws RealmUnavailableException if the realm is not able to perform the mapping * @throws IllegalArgumentException if the name is not valid * @throws SecurityException if the caller is not authorized to perform the operation */ public RealmIdentity getIdentity(String name) throws RealmUnavailableException { Assert.checkNotNullParam("name", name); return getIdentity(new NamePrincipal(name)); }
/** * Look up a {@link RealmIdentity} by name by wrapping the name in a {@link NamePrincipal} and calling {@link #getIdentity(Principal)}. * The returned identity must be {@linkplain RealmIdentity#dispose() disposed}. * * @param name the name to map (must not be {@code null}) * @return the identity for the name (not {@code null}, may be non-existent) * @throws RealmUnavailableException if the realm is not able to perform the mapping * @throws IllegalArgumentException if the name is not valid * @throws SecurityException if the caller is not authorized to perform the operation */ public RealmIdentity getIdentity(String name) throws RealmUnavailableException { Assert.checkNotNullParam("name", name); return getIdentity(new NamePrincipal(name)); }
/** * Look up a {@link RealmIdentity} by name by wrapping the name in a {@link NamePrincipal} and calling {@link #getIdentity(Principal)}. * The returned identity must be {@linkplain RealmIdentity#dispose() disposed}. * * @param name the name to map (must not be {@code null}) * @return the identity for the name (not {@code null}, may be non-existent) * @throws RealmUnavailableException if the realm is not able to perform the mapping * @throws IllegalArgumentException if the name is not valid * @throws SecurityException if the caller is not authorized to perform the operation */ public RealmIdentity getIdentity(String name) throws RealmUnavailableException { Assert.checkNotNullParam("name", name); return getIdentity(new NamePrincipal(name)); }