org.eclipse.jetty.security.DefaultUserIdentity Java Examples

The following examples show how to use org.eclipse.jetty.security.DefaultUserIdentity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyTokenAuthenticator.java    From cloud-security-xsuaa-integration with Apache License 2.0 5 votes vote down vote up
private Authentication createAuthentication(TokenAuthenticationResult tokenAuthentication) {
	Principal principal = tokenAuthentication.getPrincipal();
	Set<Principal> principals = new HashSet<>();
	principals.add(principal);
	Subject subject = new Subject(true, principals, new HashSet<>(), new HashSet<>());
	String[] scopes = tokenAuthentication.getScopes().toArray(new String[0]);
	return new UserAuthentication(getAuthMethod(), new DefaultUserIdentity(subject, principal, scopes));
}
 
Example #2
Source File: JettyTokenAuthenticator.java    From cloud-security-xsuaa-integration with Apache License 2.0 5 votes vote down vote up
private Authentication createAuthentication(TokenAuthenticationResult tokenAuthentication) {
	Principal principal = tokenAuthentication.getPrincipal();
	Set<Principal> principals = new HashSet<>();
	principals.add(principal);
	Subject subject = new Subject(true, principals, new HashSet<>(), new HashSet<>());
	String[] scopes = tokenAuthentication.getScopes().toArray(new String[0]);
	return new UserAuthentication(getAuthMethod(), new DefaultUserIdentity(subject, principal, scopes));
}
 
Example #3
Source File: AbstractKeycloakJettyAuthenticator.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static UserIdentity createIdentity(KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal) {
    Set<String> roles = AdapterUtils.getRolesFromSecurityContext(principal.getKeycloakSecurityContext());
    if (roles == null) {
        roles = new HashSet<String>();
    }
    Subject theSubject = new Subject();
    String[] theRoles = new String[roles.size()];
    roles.toArray(theRoles);

    return new DefaultUserIdentity(theSubject, principal, theRoles);
}
 
Example #4
Source File: AbstractSamlAuthenticator.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static UserIdentity createIdentity(SamlSession samlSession) {
    Set<String> roles = samlSession.getRoles();
    if (roles == null) {
        roles = new HashSet<String>();
    }
    Subject theSubject = new Subject();
    String[] theRoles = new String[roles.size()];
    roles.toArray(theRoles);

    return new DefaultUserIdentity(theSubject, samlSession.getPrincipal(), theRoles);
}