Search in sources :

Example 1 with RealmIdentity

use of org.wildfly.security.auth.server.RealmIdentity in project keycloak by keycloak.

the class KeycloakSecurityRealm method createRealmIdentity.

private RealmIdentity createRealmIdentity(KeycloakPrincipal principal) {
    return new RealmIdentity() {

        @Override
        public Principal getRealmIdentityPrincipal() {
            return principal;
        }

        @Override
        public SupportLevel getCredentialAcquireSupport(Class<? extends Credential> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException {
            return SupportLevel.UNSUPPORTED;
        }

        @Override
        public <C extends Credential> C getCredential(Class<C> credentialType) throws RealmUnavailableException {
            return null;
        }

        @Override
        public SupportLevel getEvidenceVerifySupport(Class<? extends Evidence> evidenceType, String algorithmName) throws RealmUnavailableException {
            return SupportLevel.SUPPORTED;
        }

        @Override
        public boolean verifyEvidence(Evidence evidence) throws RealmUnavailableException {
            return principal != null;
        }

        @Override
        public boolean exists() throws RealmUnavailableException {
            return principal != null;
        }

        @Override
        public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException {
            RefreshableKeycloakSecurityContext securityContext = (RefreshableKeycloakSecurityContext) principal.getKeycloakSecurityContext();
            Attributes attributes = new MapAttributes();
            Set<String> roles = AdapterUtils.getRolesFromSecurityContext(securityContext);
            attributes.addAll(RoleDecoder.KEY_ROLES, roles);
            return AuthorizationIdentity.basicIdentity(attributes);
        }
    };
}
Also used : Credential(org.wildfly.security.credential.Credential) RefreshableKeycloakSecurityContext(org.keycloak.adapters.RefreshableKeycloakSecurityContext) MapAttributes(org.wildfly.security.authz.MapAttributes) MapAttributes(org.wildfly.security.authz.MapAttributes) Attributes(org.wildfly.security.authz.Attributes) Evidence(org.wildfly.security.evidence.Evidence) RealmIdentity(org.wildfly.security.auth.server.RealmIdentity) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec)

Aggregations

AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)1 RefreshableKeycloakSecurityContext (org.keycloak.adapters.RefreshableKeycloakSecurityContext)1 RealmIdentity (org.wildfly.security.auth.server.RealmIdentity)1 Attributes (org.wildfly.security.authz.Attributes)1 MapAttributes (org.wildfly.security.authz.MapAttributes)1 Credential (org.wildfly.security.credential.Credential)1 Evidence (org.wildfly.security.evidence.Evidence)1