/** * Set the realm identity map to contain a single entry. * * @param name the entry name * @param password the password * @param attributes the identity attributes * @deprecated Use {@link #setIdentityMap(Map)} instead. */ @Deprecated public void setPasswordMap(final String name, final Password password, final Attributes attributes) { setIdentityMap(Collections.singletonMap(name, new SimpleRealmEntry( Collections.singletonList(new PasswordCredential(password)), attributes ))); }
@Override public AuthorizationIdentity getAuthorizationIdentity() { final SimpleRealmEntry entry = map.get(name); return entry == null ? AuthorizationIdentity.EMPTY : AuthorizationIdentity.basicIdentity(entry.getAttributes()); }
@Override public SupportLevel getCredentialAcquireSupport(final Class<? extends Credential> credentialType, final String algorithmName, final AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { Assert.checkNotNullParam("credentialType", credentialType); final SimpleRealmEntry entry = map.get(name); if (entry == null) return SupportLevel.UNSUPPORTED; for (Credential credential : entry.getCredentials()) { if (credential.matches(credentialType, algorithmName, parameterSpec)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override public SupportLevel getEvidenceVerifySupport(final Class<? extends Evidence> evidenceType, final String algorithmName) throws RealmUnavailableException { Assert.checkNotNullParam("evidenceType", evidenceType); SimpleRealmEntry entry = map.get(name); if (entry == null) { return SupportLevel.UNSUPPORTED; } for (Credential credential : entry.getCredentials()) { if (credential.canVerify(evidenceType, algorithmName)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
/** * Set the realm identity map to contain a single entry. * * @param name the entry name * @param password the password * @param attributes the identity attributes * @deprecated Use {@link #setIdentityMap(Map)} instead. */ @Deprecated public void setPasswordMap(final String name, final Password password, final Attributes attributes) { setIdentityMap(Collections.singletonMap(name, new SimpleRealmEntry( Collections.singletonList(new PasswordCredential(password)), attributes ))); }
@Override public AuthorizationIdentity getAuthorizationIdentity() { final SimpleRealmEntry entry = map.get(name); return entry == null ? AuthorizationIdentity.EMPTY : AuthorizationIdentity.basicIdentity(entry.getAttributes()); }
@Override public <C extends Credential> C getCredential(final Class<C> credentialType, final String algorithmName, final AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { checkNotNullParam("credentialType", credentialType); final SimpleRealmEntry entry = map.get(name); if (entry == null) return null; for (Credential credential : entry.getCredentials()) { if (credential.matches(credentialType, algorithmName, parameterSpec)) { return credentialType.cast(credential.clone()); } } return null; }
/** * Set the realm identity map to contain a single entry. * * @param name the entry name * @param password the password * @param attributes the identity attributes * @deprecated Use {@link #setIdentityMap(Map)} instead. */ @Deprecated public void setPasswordMap(final String name, final Password password, final Attributes attributes) { setIdentityMap(Collections.singletonMap(name, new SimpleRealmEntry( Collections.singletonList(new PasswordCredential(password)), attributes ))); }
@Override public AuthorizationIdentity getAuthorizationIdentity() { final SimpleRealmEntry entry = map.get(name); return entry == null ? AuthorizationIdentity.EMPTY : AuthorizationIdentity.basicIdentity(entry.getAttributes()); }
@Override public boolean verifyEvidence(final Evidence evidence) throws RealmUnavailableException { Assert.checkNotNullParam("evidence", evidence); SimpleRealmEntry entry = map.get(name); if (entry == null) { return false; } log.tracef("Trying to authenticate %s using SimpleMapBackedSecurityRealm.", name); for (Credential credential : entry.getCredentials()) { if (credential.canVerify(evidence)) { return credential.verify(providers, evidence); } } return false; }
/** * Set the realm identity map to contain a single entry. * * @param name the entry name * @param password the password * @param attributes the identity attributes * @deprecated Use {@link #setIdentityMap(Map)} instead. */ @Deprecated public void setPasswordMap(final String name, final Password password, final Attributes attributes) { setIdentityMap(Collections.singletonMap(name, new SimpleRealmEntry( Collections.singletonList(new PasswordCredential(password)), attributes ))); }
@Override public AuthorizationIdentity getAuthorizationIdentity() { final SimpleRealmEntry entry = map.get(name); return entry == null ? AuthorizationIdentity.EMPTY : AuthorizationIdentity.basicIdentity(entry.getAttributes()); }
@Override public SupportLevel getCredentialAcquireSupport(final Class<? extends Credential> credentialType, final String algorithmName, final AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { Assert.checkNotNullParam("credentialType", credentialType); final SimpleRealmEntry entry = map.get(name); if (entry == null) return SupportLevel.UNSUPPORTED; for (Credential credential : entry.getCredentials()) { if (credential.matches(credentialType, algorithmName, parameterSpec)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override protected ValueSupplier<SecurityRealm> getValueSupplier(ServiceBuilder<SecurityRealm> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String identity = IDENTITY.resolveModelAttribute(context, model).asString(); final String attributeName = ATTRIBUTE_NAME.resolveModelAttribute(context, model).asStringOrNull(); final List<String> attributeValues = ATTRIBUTE_VALUES.unwrap(context, model); return () -> { final Map<String, ? extends Collection<String>> attributesMap; if (attributeName != null) { attributesMap = Collections.singletonMap(attributeName, Collections.unmodifiableList(attributeValues)); } else { attributesMap = Collections.emptyMap(); } final Map<String, SimpleRealmEntry> realmMap = Collections.singletonMap(identity, new SimpleRealmEntry(Collections.emptyList(), new MapAttributes(attributesMap))); SimpleMapBackedSecurityRealm securityRealm = new SimpleMapBackedSecurityRealm(); securityRealm.setPasswordMap(realmMap); return securityRealm; }; } };
@Override public SupportLevel getCredentialAcquireSupport(final Class<? extends Credential> credentialType, final String algorithmName, final AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { Assert.checkNotNullParam("credentialType", credentialType); final SimpleRealmEntry entry = map.get(name); if (entry == null) return SupportLevel.UNSUPPORTED; for (Credential credential : entry.getCredentials()) { if (credential.matches(credentialType, algorithmName, parameterSpec)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override public SupportLevel getCredentialAcquireSupport(final Class<? extends Credential> credentialType, final String algorithmName, final AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { Assert.checkNotNullParam("credentialType", credentialType); final SimpleRealmEntry entry = map.get(name); if (entry == null) return SupportLevel.UNSUPPORTED; for (Credential credential : entry.getCredentials()) { if (credential.matches(credentialType, algorithmName, parameterSpec)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override public SupportLevel getEvidenceVerifySupport(final Class<? extends Evidence> evidenceType, final String algorithmName) throws RealmUnavailableException { Assert.checkNotNullParam("evidenceType", evidenceType); SimpleRealmEntry entry = map.get(name); if (entry == null) { return SupportLevel.UNSUPPORTED; } for (Credential credential : entry.getCredentials()) { if (credential.canVerify(evidenceType, algorithmName)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override public SupportLevel getEvidenceVerifySupport(final Class<? extends Evidence> evidenceType, final String algorithmName) throws RealmUnavailableException { Assert.checkNotNullParam("evidenceType", evidenceType); SimpleRealmEntry entry = map.get(name); if (entry == null) { return SupportLevel.UNSUPPORTED; } for (Credential credential : entry.getCredentials()) { if (credential.canVerify(evidenceType, algorithmName)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override public SupportLevel getEvidenceVerifySupport(final Class<? extends Evidence> evidenceType, final String algorithmName) throws RealmUnavailableException { Assert.checkNotNullParam("evidenceType", evidenceType); SimpleRealmEntry entry = map.get(name); if (entry == null) { return SupportLevel.UNSUPPORTED; } for (Credential credential : entry.getCredentials()) { if (credential.canVerify(evidenceType, algorithmName)) { return SupportLevel.SUPPORTED; } } return SupportLevel.UNSUPPORTED; }
@Override public <C extends Credential> C getCredential(final Class<C> credentialType, final String algorithmName, final AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { checkNotNullParam("credentialType", credentialType); final SimpleRealmEntry entry = map.get(name); if (entry == null) return null; for (Credential credential : entry.getCredentials()) { if (credential.matches(credentialType, algorithmName, parameterSpec)) { return credentialType.cast(credential.clone()); } } return null; }