Example usage for org.apache.shiro.authz.permission WildcardPermissionResolver WildcardPermissionResolver

List of usage examples for org.apache.shiro.authz.permission WildcardPermissionResolver WildcardPermissionResolver

Introduction

In this page you can find the example usage for org.apache.shiro.authz.permission WildcardPermissionResolver WildcardPermissionResolver.

Prototype

public WildcardPermissionResolver() 

Source Link

Document

Default constructor.

Usage

From source file:com.stormpath.shiro.realm.CustomDataPermissionResolver.java

License:Apache License

/**
 * Creates a new instance, using the default {@link #getCustomDataFieldName() customDataFieldName} of
 * {@code apacheShiroPermissions} and a default {@link WildcardPermissionResolver}.
 *///w w  w .  ja  v a  2  s. c om
public CustomDataPermissionResolver() {
    this.customDataFieldName = CustomDataPermissionsEditor.DEFAULT_CUSTOM_DATA_FIELD_NAME;
    this.permissionResolver = new WildcardPermissionResolver();
}

From source file:com.yea.shiro.mgt.ShiroSecurityManager.java

License:Apache License

public ShiroSecurityManager() {
    super();//from   ww  w  .j a va 2s  . co  m
    // authenticator
    ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator();
    authenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
    setAuthenticator(authenticator);

    // authorizer
    ModularRealmAuthorizer authorizer = new ModularRealmAuthorizer();
    authorizer.setPermissionResolver(new WildcardPermissionResolver());
    setAuthorizer(authorizer);

    // ?Matcher
    credentialsMatcher = new RetryLimitHashedCredentialsMatcher();
    credentialsMatcher.setHashAlgorithmName(EncrytPassword.PASSWORD_HASH);
    credentialsMatcher.setHashIterations(EncrytPassword.HASH_ITERATIONS);
    credentialsMatcher.setStoredCredentialsHexEncoded(true);

}

From source file:com.yea.shiro.web.mgt.WebSecurityManager.java

License:Apache License

public WebSecurityManager() {
    super();/*from  w ww.j av  a 2  s. co  m*/
    // authenticator
    ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator();
    authenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
    setAuthenticator(authenticator);

    // authorizer
    ModularRealmAuthorizer authorizer = new ModularRealmAuthorizer();
    authorizer.setPermissionResolver(new WildcardPermissionResolver());
    setAuthorizer(authorizer);

    // ?Matcher
    credentialsMatcher = new RetryLimitHashedCredentialsMatcher();
    credentialsMatcher.setHashAlgorithmName(EncrytPassword.PASSWORD_HASH);
    credentialsMatcher.setHashIterations(EncrytPassword.HASH_ITERATIONS);
    credentialsMatcher.setStoredCredentialsHexEncoded(true);

}

From source file:org.mobicents.servlet.restcomm.http.SecuredEndpoint.java

License:Open Source License

/**
 * Low level permission checking. roleNames are checked for neededPermissionString permission using permission
 * mappings contained in restcomm.xml. The permission mappings are stored in RestcommRoles.
 *
 * Note: Administrator is granted access with eyes closed
        //from   ww w  .j a v a 2 s .  c  om
 * @param neededPermissionString
 * @param roleNames
 * @return
 */
private AuthOutcome checkPermission(String neededPermissionString, Set<String> roleNames) {
    // if this is an administrator ask no more questions
    if (roleNames.contains(getAdministratorRole()))
        return AuthOutcome.OK;

    // normalize the permission string
    //neededPermissionString = "domain:" + neededPermissionString;

    WildcardPermissionResolver resolver = new WildcardPermissionResolver();
    Permission neededPermission = resolver.resolvePermission(neededPermissionString);

    // check the neededPermission against all roles of the user
    RestcommRoles restcommRoles = identityContext.getRestcommRoles();
    for (String roleName : roleNames) {
        SimpleRole simpleRole = restcommRoles.getRole(roleName);
        if (simpleRole == null) {
            return AuthOutcome.FAILED;
        } else {
            Set<Permission> permissions = simpleRole.getPermissions();
            // check the permissions one by one
            for (Permission permission : permissions) {
                if (permission.implies(neededPermission)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Granted access by permission " + permission.toString());
                    }
                    return AuthOutcome.OK;
                }
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Role " + roleName + " does not allow " + neededPermissionString);
            }
        }
    }
    return AuthOutcome.FAILED;
}

From source file:org.owasp.dependencytrack.config.SecurityConfiguration.java

License:Open Source License

@Bean
public WildcardPermissionResolver permissionResolver() {
    return new WildcardPermissionResolver();
}