Package java.security

Examples of java.security.Principal


   
    private HttpServletRequest createSecurityContext(HttpServletRequest request,
                                                     String username,
                                                     String password)
    {
        final Principal principal = new SimplePrincipal(username);
        Subject subject = new Subject();
        if (am.isValid(principal, password, subject) == false)
        {
            String msg = "Authentication failed, principal=" + principal.getName();
            throw new SecurityException(msg);
        }
       
        final Set<String> roles = getRoles(subject);
       
View Full Code Here


        throws ServletException, IOException
    {
    String[] values = req.getParameterValues("xopenid.realm");
    if (values != null && values.length > 0)
    {
        Principal principal = req.getUserPrincipal();
        if (principal == null)
        {
            resp.setStatus(401);
            return;
        }
      trustedRealmsMap.putIfAbsent(principal.getName(),
              new HashSet<String>(Arrays.asList(values)));
    }
    }
View Full Code Here

    SubscriptionResponse response = new SubscriptionResponse();
    response.setSuccess(true);
    HttpServletRequest request = getThreadLocalRequest();
    HttpSession session = request.getSession();
    String publisher = (String) session.getAttribute("UserName");
    Principal user = request.getUserPrincipal();
    if (publisher==null && user!=null) {
      logger.debug("UserPrincipal " + user);
      publisher = user.getName();
    }
    logger.debug("Publisher " + publisher + " sending getSubscription request..");
    try {
      boolean isMatchingClerk=false;
      UDDIClerk toClerk = null;
View Full Code Here

   
    HttpServletRequest request = getThreadLocalRequest();
    HttpSession session = request.getSession();
    String username = (String) session.getAttribute("UserName");
    if (username==null) {
      Principal user = request.getUserPrincipal();
      if (user!=null) {
        username = user.getName();
      }
    }
    GetPublisherDetail getPublisherDetail = new GetPublisherDetail();
    getPublisherDetail.setAuthInfo(authToken);
    getPublisherDetail.getPublisherId().add(username);
View Full Code Here

        
         List<Permission> permissions = new ArrayList<Permission>();
  
         for (String role : selectedRoles)
         {
            Principal r = new Role(role);
            for (String action : selectedActions)
            {           
               permissions.add(new Permission(target, action, r));
            }
         }
        
         for (Member friend : selectedFriends)
         {
            MemberAccount acct = (MemberAccount) entityManager.createQuery(
                  "select a from MemberAccount a where a.member = :member")
                  .setParameter("member", friend)
                  .getSingleResult();
           
            Principal p = new SimplePrincipal(acct.getUsername());
           
            for (String action : selectedActions)
            {
               permissions.add(new Permission(target, action, p));
            }
View Full Code Here

    SecurityResponse response = new SecurityResponse();
    String token = (String) session.getAttribute("AuthToken");
    if (username==null) {
      username = (String) session.getAttribute("UserName");
    }
    Principal user = request.getUserPrincipal();
    log.debug("UserPrincipal " + user);
    if (username==null && user!=null) {
      username = user.getName();
      password = "";
    }
    if (token==null) {
      if (username==null) {
        log("Could not obtain username, this session is invalid.");
View Full Code Here

    }

    private void assertAuthenticate(String login, String password, String xwikiUserName, String storedDn,
        String storedUid) throws XWikiException
    {
        Principal principal = this.ldapAuth.authenticate(login, password, getContext());

        // Check that authentication return a valid Principal
        assertNotNull("Authentication failed", principal);

        // Check that the returned Principal has the good name
        assertEquals("Wrong returned principal", xwikiUserName, principal.getName());

        XWikiDocument userProfile = getDocument(xwikiUserName);

        // check hat user has been created
        assertTrue("The user profile has not been created", !userProfile.isNew());
View Full Code Here

    /**
     * Validate "simple" LDAP authentication fail with wrong user.
     */
    public void testAuthenticateWithWrongUser() throws XWikiException
    {
        Principal principal = this.ldapAuth.authenticate("WrongUser", "WrongPass", getContext());

        // Check that authentication return a null Principal
        assertNull(principal);

        XWikiDocument userProfile = getDocument("XWiki.WrongUser");
View Full Code Here

    }
   
    protected HttpServletRequest createSecurityContext(HttpServletRequest request,
            OAuthConsumer consumer, OAuthToken accessToken)
    {
        final Principal principal = new SimplePrincipal(consumer.getKey());
        final Set<String> roles = getRoles(consumer);
       
        return new HttpServletRequestWrapper(request){
            @Override
            public Principal getUserPrincipal(){
View Full Code Here

     */
    protected void verify(String host, SSLSession session) throws Exception {

        X509Certificate[] chain;
        X509Certificate   certificate;
        Principal         principal;
        PublicKey         publicKey;
        String            DN;
        String            CN;
        int               start;
        int               end;
View Full Code Here

TOP

Related Classes of java.security.Principal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.