Examples of Principal


Examples of be.c4j.demo.security.demo.model.Principal

    @Inject
    private PermissionService permissionService;

    @Override
    public AuthenticationInfo getAuthenticationInfo(UsernamePasswordToken token) {
        Principal principal = permissionService.getPrincipalByUserName(token.getUsername());

        if (principal == null) {
            return null;
        } else {

            AuthenticationInfoBuilder authenticationInfoBuilder = new AuthenticationInfoBuilder();
            authenticationInfoBuilder.principalId(principal.getId()).name(principal.getEmployee().getName());
            authenticationInfoBuilder.password(principal.getPassword()) ;

            authenticationInfoBuilder.addUserInfo(UserInfo.EMPLOYEE_ID, principal.getEmployee().getId());
            if (principal.getEmployee().getDepartment() != null) {

                authenticationInfoBuilder.addUserInfo(UserInfo.DEPARTMENT_ID, principal.getEmployee().getDepartment().getId());
            }

            if (principal.getEmployee().getManager() != null) {
                authenticationInfoBuilder.addUserInfo(UserInfo.MANAGER_EMPLOYEE_ID, principal.getEmployee().getManager().getId());
            }


            return authenticationInfoBuilder.build();
        }
View Full Code Here

Examples of com.adito.policyframework.Principal

        UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
        if (pol.getResourceId() != PolicyDatabaseFactory.getInstance().getEveryonePolicyIDForRealm(udb.getRealm())) {
            List wasAttached = PolicyDatabaseFactory.getInstance().getPrincipalsGrantedPolicy(pol, udb.getRealm()); // objects
            List nowAttached = policyForm.getSelectedAccountsList();
            for (Iterator i = wasAttached.iterator(); i.hasNext();) {
                Principal p = (Principal) i.next();
                try {
                    if (!nowAttached.contains(p.getPrincipalName())) {
                        CoreServlet.getServlet().fireCoreEvent(
                            new CoreEvent(this, CoreEventConstants.REVOKE_POLICY_FROM_PRINCIPAL, null, null,
                                            CoreEvent.STATE_SUCCESSFUL).addAttribute(
                                CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE, p instanceof User ? "user" : "group")
                                            .addAttribute(CoreAttributeConstants.EVENT_ATTR_POLICY_NAME, pol.getResourceName())
                                            .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, p.getPrincipalName()));

                    }
                } catch (Exception e) {
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, CoreEventConstants.REVOKE_POLICY_FROM_PRINCIPAL, null, null, e).addAttribute(
                            CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE, p instanceof User ? "user" : "group").addAttribute(
                            CoreAttributeConstants.EVENT_ATTR_POLICY_NAME, pol.getResourceName()).addAttribute(
                            CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, p.getPrincipalName()));
                    throw e;
                }
            }

            // TODO fire revoking events
            PolicyDatabaseFactory.getInstance().revokePolicyFromAllPrincipals(pol, udb.getRealm());
            for (Iterator i = nowAttached.iterator(); i.hasNext();) {
                Principal p = udb.getAccount((String) i.next());
                try {
                    PolicyDatabaseFactory.getInstance().grantPolicyToPrincipal(pol, p);
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, CoreEventConstants.GRANT_POLICY_TO_PRINCIPAL, null, null, CoreEvent.STATE_SUCCESSFUL)
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE,
                                            "user").addAttribute(
                                            CoreAttributeConstants.EVENT_ATTR_POLICY_NAME, pol.getResourceName()).addAttribute(
                                            CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, p.getPrincipalName()));
                } catch (Exception e) {
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, CoreEventConstants.GRANT_POLICY_TO_PRINCIPAL, null, null, e).addAttribute(
                            CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE, "user").addAttribute(
                            CoreAttributeConstants.EVENT_ATTR_POLICY_NAME, pol.getResourceName()).addAttribute(
                            CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, p.getPrincipalName()));
                    throw e;
                }
            }
            for (Iterator i = policyForm.getSelectedRolesList().iterator(); i.hasNext();) {
                Principal p = udb.getRole((String) i.next());
                try {
                    PolicyDatabaseFactory.getInstance().grantPolicyToPrincipal(pol, p);
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, CoreEventConstants.GRANT_POLICY_TO_PRINCIPAL, null, null, CoreEvent.STATE_SUCCESSFUL)
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE, "group")
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_POLICY_NAME, pol.getResourceName())
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, p.getPrincipalName()));
                } catch (Exception e) {
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, CoreEventConstants.GRANT_POLICY_TO_PRINCIPAL, null, null, CoreEvent.STATE_UNSUCCESSFUL)
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE, "group")
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_POLICY_NAME, pol.getResourceName())
                                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, p.getPrincipalName()));
                    throw e;
                }
            }
        }
        // Update the attributes
View Full Code Here

Examples of com.amazonaws.auth.policy.Principal

     *            request.
     * @return a principal instance.
     */
    private Principal createPrincipal(String schema, JsonNode principalNode) {
        if (schema.equalsIgnoreCase(PRINCIPAL_SCHEMA_USER)) {
            return new Principal(principalNode.asText());
        } else if (schema.equalsIgnoreCase(PRINCIPAL_SCHEMA_SERVICE)) {
            return new Principal(Services.fromString(principalNode.asText()));
        } else if (schema.equalsIgnoreCase(PRINICIPAL_SCHEMA_FEDERATED)) {
            if (WebIdentityProviders.fromString(principalNode.asText()) != null) {
                return new Principal(
                        WebIdentityProviders.fromString(principalNode.asText()));
            } else {
                return new Principal(PRINICIPAL_SCHEMA_FEDERATED, principalNode.asText());
            }
        }
        throw new AmazonClientException("Schema " + schema + " is not a valid value for the principal.");
    }
View Full Code Here

Examples of com.github.ebnew.ki4so.core.authentication.Principal

        Map<String, Object> param = new HashMap<String, Object>();
        encryCredential.setParameters(param);
        EncryCredentialInfo encryCredentialInfo = new EncryCredentialInfo();
        encryCredentialInfo.setUserId(userId);
        encryCredential.setEncryCredentialInfo(encryCredentialInfo);
        Principal principal = this.resolver.resolvePrincipal(encryCredential);
        assertNotNull(principal);
        assertEquals(userId, principal.getId());
        assertEquals(param, principal.getAttributes());
    }
View Full Code Here

Examples of com.github.sardine.model.Principal

  }

  public Ace toModel()
  {
    Ace ace = new Ace();
    Principal p = new Principal();
    switch (principal.getPrincipalType())
    {
      case HREF:
        p.setHref(principal.getValue());
        break;
      case PROPERTY:
        p.setProperty(new Property());
        p.getProperty().setProperty(SardineUtil.createElement(principal.getProperty()));
        break;
      case KEY:
        if (DavPrincipal.KEY_ALL.equals(principal.getValue()))
        {
          p.setAll(new All());
        }
        else if (DavPrincipal.KEY_AUTHENTICATED.equals(principal.getValue()))
        {
          p.setAuthenticated(new Authenticated());
        }
        else if (DavPrincipal.KEY_UNAUTHENTICATED.equals(principal.getValue()))
        {
          p.setUnauthenticated(new Unauthenticated());
        }
        else if (DavPrincipal.KEY_SELF.equals(principal.getValue()))
        {
          p.setSelf(new Self());
        }
    }
    ace.setPrincipal(p);
    if (granted != null && granted.size() > 0)
    {
View Full Code Here

Examples of com.google.enterprise.connector.spi.Principal

    NotesConnectorDocument document = new NotesConnectorDocument(
        connectorSession, session, connectorDatabase);
    document.setCrawlDoc("unid", crawlDoc);

    // Check defaults.
    Principal principal =
        getFirstPrincipal(document, SpiConstants.PROPNAME_ACLUSERS);
    assertEquals(new Principal(PrincipalType.UNKNOWN,
            connector.getGlobalNamespace(), "jsmith",
            CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE), principal);
    principal = getFirstPrincipal(document, SpiConstants.PROPNAME_ACLGROUPS);
    assertEquals(new Principal(PrincipalType.UNQUALIFIED,
            connector.getLocalNamespace(), "Domino%2Freadergroup",
            CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE), principal);

    // Change usernames to local namespace. Groups should stay local.
    try {
      connector.setGsaNamesAreGlobal(false);
      document =
          new NotesConnectorDocument(connectorSession, session, connectorDatabase);
      document.setCrawlDoc("unid", crawlDoc);
      principal = getFirstPrincipal(document, SpiConstants.PROPNAME_ACLUSERS);
      assertEquals(new Principal(PrincipalType.UNQUALIFIED,
              connector.getLocalNamespace(), "jsmith",
              CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE), principal);

      principal = getFirstPrincipal(document, SpiConstants.PROPNAME_ACLGROUPS);
      assertEquals(new Principal(PrincipalType.UNQUALIFIED,
              connector.getLocalNamespace(), "Domino%2Freadergroup",
              CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE), principal);
    } finally {
      connector.setGsaNamesAreGlobal(true);
    }
View Full Code Here

Examples of com.sun.enterprise.deployment.runtime.connector.Principal

  MapElement descriptor = (MapElement) getDescriptor();
  if (descriptor==null) {
      throw new RuntimeException("Cannot set info on null descriptor");
  }
  if (newDescriptor instanceof Principal) {
      Principal principal = (Principal) newDescriptor;
      if (principal.getValue(Principal.CREDENTIAL)==null) {
    descriptor.addPrincipal(principal);
      } else {
    descriptor.setBackendPrincipal(true);
    descriptor.setAttributeValue(MapElement.BACKEND_PRINCIPAL, Principal.USER_NAME, principal.getValue(Principal.USER_NAME));
    descriptor.setAttributeValue(MapElement.BACKEND_PRINCIPAL, Principal.PASSWORD, principal.getValue(Principal.PASSWORD));
    descriptor.setAttributeValue(MapElement.BACKEND_PRINCIPAL, Principal.CREDENTIAL, principal.getValue(Principal.CREDENTIAL));
   
      }
  }
    }
View Full Code Here

Examples of com.sun.enterprise.tools.common.dd.connector.Principal

               allPrincipals = allPrincipals.substring(0,len-2);
           return allPrincipals;
*/
           Vector vec = new Vector();
           for (int i = 0; i < me.sizePrincipal(); i++) {
               Principal prin = me.getPrincipal(i);
               String[] element = new String[2];
               element[0] = prin.getAttributeValue("user-name");   //NOI18N
               element[1] = prin.getDescription();
               vec.add(element);
           }
           Reporter.info(new Integer(vec.size()));
           return vec;
       }
View Full Code Here

Examples of com.sun.enterprise.tools.common.dd.ejb.Principal

       
        if(ejbJar!=null)
        {
            testCase = super.getEjb(descriptor.getName(),ejbJar);
           
            Principal principal = testCase.getPrincipal();
            if(principal == null)
            {
                result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                    "NOT APPLICABLE [AS-EJB ejb] : principal element not defined"));
            }
            else
            {
                String principalName = principal.getName();
                if(principalName.length()==0)
                {
                    result.failed(smh.getLocalString(getClass().getName()+".failed",
                        "FAILED [AS-EJB principal] : name cannot be an empty String"));
                }
View Full Code Here

Examples of com.thinkgem.jeesite.modules.sys.security.SystemAuthorizingRealm.Principal

  public static User getUser(){
    User user = (User)getCache(CACHE_USER);
    if (user == null){
      try{
        Subject subject = SecurityUtils.getSubject();
        Principal principal = (Principal)subject.getPrincipal();
        if (principal!=null){
          user = userDao.get(principal.getId());
//          Hibernate.initialize(user.getRoleList());
          putCache(CACHE_USER, user);
        }
      }catch (UnavailableSecurityManagerException e) {
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.