List of usage examples for javax.security.auth Subject getPrincipals
public Set<Principal> getPrincipals()
From source file:net.sourceforge.safr.sample.Sample.java
private static void addUserPrincipal(Subject subject, User user) { subject.getPrincipals().add(new UserPrincipal(user.getId())); }
From source file:net.sourceforge.safr.sample.Sample.java
private static void addRolePrincipals(Subject subject, User user) { for (Role role : user.getRoles()) { subject.getPrincipals().add(new RolePrincipal(role.getId())); }//from w w w . ja v a2 s. com }
From source file:cz.ceskaexpedice.k5.k5jaas.basic.K5LoginModule.java
public static void assignPrincipal(Subject subject, Principal principal) { if (!subject.getPrincipals().contains(principal)) { subject.getPrincipals().add(principal); }/* w w w. ja va2 s.co m*/ }
From source file:org.apache.hadoop.security.SecureClientLogin.java
public synchronized static Subject login(String user) throws IOException { Subject subject = new Subject(); subject.getPrincipals().add(new User(user)); return subject; }
From source file:org.apache.storm.blobstore.BlobStoreUtils.java
public static Subject getNimbusSubject() { Subject subject = new Subject(); subject.getPrincipals().add(new NimbusPrincipal()); return subject; }
From source file:org.apache.qpid.server.management.plugin.HttpManagementUtil.java
public static void checkRequestAuthenticatedAndAccessAuthorized(HttpServletRequest request, Broker broker, HttpManagementConfiguration managementConfig) { HttpSession session = request.getSession(); Subject subject = getAuthorisedSubject(session); if (subject == null) { subject = tryToAuthenticate(request, managementConfig); if (subject == null) { throw new SecurityException("Only authenticated users can access the management interface"); }// w w w. j ava 2 s . c o m Subject original = subject; subject = new Subject(false, original.getPrincipals(), original.getPublicCredentials(), original.getPrivateCredentials()); subject.getPrincipals().add(new ServletConnectionPrincipal(request)); subject.setReadOnly(); assertManagementAccess(broker.getSecurityManager(), subject); saveAuthorisedSubject(session, subject); } }
From source file:org.apache.hadoop.security.SecureClientLogin.java
public synchronized static Subject loginUserFromKeytab(String user, String path) throws IOException { try {/*ww w .j a v a 2s. com*/ Subject subject = new Subject(); SecureClientLoginConfiguration loginConf = new SecureClientLoginConfiguration(true, user, path); LoginContext login = new LoginContext("hadoop-keytab-kerberos", subject, null, loginConf); subject.getPrincipals().add(new User(user, AuthenticationMethod.KERBEROS, login)); login.login(); return login.getSubject(); } catch (LoginException le) { throw new IOException("Login failure for " + user + " from keytab " + path, le); } }
From source file:org.apache.hadoop.security.SecureClientLogin.java
public synchronized static Subject loginUserWithPassword(String user, String password) throws IOException { String tmpPass = password;/* ww w. j a v a 2 s . co m*/ try { Subject subject = new Subject(); SecureClientLoginConfiguration loginConf = new SecureClientLoginConfiguration(false, user, password); LoginContext login = new LoginContext("hadoop-keytab-kerberos", subject, null, loginConf); subject.getPrincipals().add(new User(user, AuthenticationMethod.KERBEROS, login)); login.login(); return login.getSubject(); } catch (LoginException le) { throw new IOException("Login failure for " + user + " using password " + tmpPass.replaceAll(".", "*"), le); } }
From source file:lia.gsi.net.GSIGssSocketFactory.java
/** * Retrieve the Globus Subject from a GssSocket * /* www . ja va 2 s. c o m*/ * @param socket * @return javax.security.auth.Subject having a single Principal elementt : The Globus DN * @throws GSSException * if the supplied socket is not a GssSocket or the Globus Credentials is not set on the socket */ public static Subject getLocalSubject(Socket socket) throws GSSException { if (!(socket instanceof GssSocket)) throw new GSSException(GSSException.NO_CRED); GssSocket gssSocket; gssSocket = (GssSocket) socket; Subject mySubject = new Subject(); GlobusPrincipal nm; try { nm = JaasGssUtil.toGlobusPrincipal(gssSocket.getContext().getSrcName()); } catch (Throwable t) { throw new GSSException(GSSException.NO_CRED); } mySubject.getPrincipals().add(nm); return mySubject; }
From source file:backtype.storm.blobstore.BlobStoreTest.java
public static Subject getNimbusSubject() { Subject nimbus = new Subject(); nimbus.getPrincipals().add(new NimbusPrincipal()); return nimbus; }