Search in sources :

Example 1 with KnownUser

use of org.eclipse.jetty.security.MappedLoginService.KnownUser in project zm-mailbox by Zimbra.

the class ZimbraLoginService method makeUserIdentity.

UserIdentity makeUserIdentity(String userName) {
    // blank password/credentials. this is just a placeholder; we always
    // check credentials via prov on each login
    Credential credential = Credential.getCredential("");
    // only need 'user' role for current implementation protecting
    // /zimbra/downloads - expand to admin if needed later
    String roleName = "user";
    Principal userPrincipal = new KnownUser(userName, credential);
    Subject subject = new Subject();
    subject.getPrincipals().add(userPrincipal);
    subject.getPrivateCredentials().add(credential);
    subject.getPrincipals().add(new RolePrincipal(roleName));
    subject.setReadOnly();
    UserIdentity identity = identityService.newUserIdentity(subject, userPrincipal, new String[] { roleName });
    return identity;
}
Also used : Credential(org.eclipse.jetty.util.security.Credential) KnownUser(org.eclipse.jetty.security.MappedLoginService.KnownUser) UserIdentity(org.eclipse.jetty.server.UserIdentity) RolePrincipal(org.eclipse.jetty.security.MappedLoginService.RolePrincipal) RolePrincipal(org.eclipse.jetty.security.MappedLoginService.RolePrincipal) Principal(java.security.Principal) Subject(javax.security.auth.Subject)

Aggregations

Principal (java.security.Principal)1 Subject (javax.security.auth.Subject)1 KnownUser (org.eclipse.jetty.security.MappedLoginService.KnownUser)1 RolePrincipal (org.eclipse.jetty.security.MappedLoginService.RolePrincipal)1 UserIdentity (org.eclipse.jetty.server.UserIdentity)1 Credential (org.eclipse.jetty.util.security.Credential)1