Search in sources :

Example 6 with Credential

use of org.eclipse.jetty.util.security.Credential 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)

Example 7 with Credential

use of org.eclipse.jetty.util.security.Credential in project jena by apache.

the class FusekiTestAuth method makeUserStore.

/** Very simple! */
private static UserStore makeUserStore(String user, String password, String role) {
    Credential cred = new Password(password);
    PropertyUserStore propertyUserStore = new PropertyUserStore();
    String[] roles = role == null ? null : new String[] { role };
    propertyUserStore.addUser(user, cred, roles);
    try {
        propertyUserStore.start();
    } catch (Exception ex) {
        throw new FusekiException("UserStore", ex);
    }
    return propertyUserStore;
}
Also used : Credential(org.eclipse.jetty.util.security.Credential) FusekiException(org.apache.jena.fuseki.FusekiException) HttpException(org.apache.jena.atlas.web.HttpException) FusekiException(org.apache.jena.fuseki.FusekiException) Password(org.eclipse.jetty.util.security.Password)

Aggregations

Credential (org.eclipse.jetty.util.security.Credential)7 Principal (java.security.Principal)4 Subject (javax.security.auth.Subject)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Properties (java.util.Properties)2 UserIdentity (org.eclipse.jetty.server.UserIdentity)2 ArrayList (java.util.ArrayList)1 Attributes (javax.naming.directory.Attributes)1 HttpException (org.apache.jena.atlas.web.HttpException)1 FusekiException (org.apache.jena.fuseki.FusekiException)1 KnownUser (org.eclipse.jetty.security.MappedLoginService.KnownUser)1 RolePrincipal (org.eclipse.jetty.security.MappedLoginService.RolePrincipal)1 PropertyUserStore (org.eclipse.jetty.security.PropertyUserStore)1 Password (org.eclipse.jetty.util.security.Password)1 GetResponse (org.elasticsearch.action.get.GetResponse)1 GetField (org.elasticsearch.index.get.GetField)1 IndexMissingException (org.elasticsearch.indices.IndexMissingException)1