当前位置: 首页>>代码示例>>Java>>正文


Java RealmUnavailableException类代码示例

本文整理汇总了Java中org.wildfly.security.auth.server.RealmUnavailableException的典型用法代码示例。如果您正苦于以下问题:Java RealmUnavailableException类的具体用法?Java RealmUnavailableException怎么用?Java RealmUnavailableException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RealmUnavailableException类属于org.wildfly.security.auth.server包,在下文中一共展示了RealmUnavailableException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeRuntimeStep

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    String principalName = IDENTITY.resolveModelAttribute(context, operation).asString();
    ModifiableSecurityRealm modifiableRealm = getModifiableSecurityRealm(context);

    ModifiableRealmIdentity identity = null;
    try {
        identity = modifiableRealm.getRealmIdentityForUpdate(new NamePrincipal(principalName));

        if (!identity.exists()) {
            throw new OperationFailedException(ROOT_LOGGER.identityNotFound(principalName));
        }

        identity.delete();
        identity.dispose();
    } catch (RealmUnavailableException e) {
        throw ROOT_LOGGER.couldNotDeleteIdentity(principalName, e);
    } finally {
        if (identity != null) {
            identity.dispose();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:ModifiableRealmDecorator.java

示例2: getRealmIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
/**
 * Try to obtain a {@link ModifiableRealmIdentity} based on the identity and {@link ModifiableSecurityRealm} associated with given {@link OperationContext}.
 *
 * @param context the current context
 * @return the current identity
 * @throws OperationFailedException if the identity does not exists or if any error occurs while obtaining it.
 */
static ModifiableRealmIdentity getRealmIdentity(OperationContext context, String principalName) throws OperationFailedException {
    ModifiableSecurityRealm modifiableRealm = getModifiableSecurityRealm(context);
    ModifiableRealmIdentity realmIdentity = null;
    try {
        realmIdentity = modifiableRealm.getRealmIdentityForUpdate(new NamePrincipal(principalName));

        if (!realmIdentity.exists()) {
            throw new OperationFailedException(ROOT_LOGGER.identityNotFound(principalName));
        }

        return realmIdentity;
    } catch (RealmUnavailableException e) {
        throw ROOT_LOGGER.couldNotReadIdentity(principalName, e);
    } finally {
        if (realmIdentity != null) {
            realmIdentity.dispose();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:ModifiableRealmDecorator.java

示例3: performOutflow

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
private static SecurityIdentity[] performOutflow(SecurityIdentity identity, boolean outflowAnonymous, Set<SecurityDomain> outflowDomains) {
    List<SecurityIdentity> outflowIdentities = new ArrayList<>(outflowDomains.size());
    for (SecurityDomain d : outflowDomains) {
        ServerAuthenticationContext sac = d.createNewAuthenticationContext();
        try {
            if (sac.importIdentity(identity)) {
                outflowIdentities.add(sac.getAuthorizedIdentity());
            } else if (outflowAnonymous) {
                outflowIdentities.add(d.getAnonymousSecurityIdentity());
            }
        } catch (RealmUnavailableException e) {
            throw ROOT_LOGGER.unableToPerformOutflow(identity.getPrincipal().getName(), e);
        }
    }

    return outflowIdentities.toArray(new SecurityIdentity[outflowIdentities.size()]);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:DomainDefinition.java

示例4: verifyEvidence

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public boolean verifyEvidence(Evidence evidence) throws RealmUnavailableException {
    if (user == null || evidence instanceof PasswordGuessEvidence == false) {
        return false;
    }
    final char[] guess = ((PasswordGuessEvidence) evidence).getGuess();

    String password = user.require(PASSWORD).asString();
    final PasswordFactory passwordFactory = getPasswordFactory(ALGORITHM_CLEAR);
    final PasswordSpec passwordSpec = new ClearPasswordSpec(password.toCharArray());
    final Password actualPassword;

    try {
        actualPassword = passwordFactory.generatePassword(passwordSpec);

        return passwordFactory.verify(actualPassword, guess);
    } catch (InvalidKeySpecException | InvalidKeyException | IllegalStateException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:UserDomainCallbackHandler.java

示例5: restoreIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
private boolean restoreIdentity() {
    if (securityDomain == null) {
        return false;
    }

    HttpScope sessionScope = httpExchange.getScope(Scope.SESSION);
    if (sessionScope != null && sessionScope.supportsAttachments()) {
        String principalName = sessionScope.getAttachment(AUTHENTICATED_PRINCIPAL_KEY, String.class);
        if (principalName != null) {
            ServerAuthenticationContext authenticationContext = securityDomain.createNewAuthenticationContext();
            try {
                authenticationContext.setAuthenticationName(principalName);
                if (authenticationContext.authorize()) {
                    SecurityIdentity authorizedIdentity = authenticationContext.getAuthorizedIdentity();
                    authenticationComplete(new ElytronAccount(authorizedIdentity), programaticMechanismName, false);
                    setupProgramaticLogout(sessionScope);

                    return true;
                } else {
                    sessionScope.setAttachment(AUTHENTICATED_PRINCIPAL_KEY, null); // Whatever was in there no longer works so just drop it.
                }
            } catch (IllegalArgumentException | RealmUnavailableException | IllegalStateException e) {
                authenticationFailed(e.getMessage(), programaticMechanismName);
            }
        }
    }

    return false;
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:30,代码来源:SecurityContextImpl.java

示例6: roleToSecurityIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
private static SecurityIdentity roleToSecurityIdentity(StandardRole role) throws RealmUnavailableException {
    if (role == null) {
        return testDomain.getAnonymousSecurityIdentity();
    }

    ServerAuthenticationContext authenticationContext = testDomain.createNewAuthenticationContext();
    authenticationContext.setAuthenticationName(roleToUserName(role));
    assertTrue("Authorized", authenticationContext.authorize());

    return authenticationContext.getAuthorizedIdentity();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:JmxFacadeRbacEnabledTestCase.java

示例7: getRealmIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public RealmIdentity getRealmIdentity(Principal principal) throws RealmUnavailableException {
    String name = principal.getName();
    if (allowAll || allowedUsersSet.contains(name)) {
        return new LocalRealmIdentity(principal);
    }

    return RealmIdentity.NON_EXISTENT;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:LocalCallbackHandlerService.java

示例8: getAuthorizationIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException {
    List<String> list = new ArrayList<>();
    for (RealmGroup realmGroup : subject.getPrincipals(RealmGroup.class)) {
        String realmGroupName = realmGroup.getName();
        list.add(realmGroupName);
    }
    Attributes attributes = new MapAttributes(Collections.singletonMap("GROUPS",
        list));
    return AuthorizationIdentity.basicIdentity(attributes);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:JaasCallbackHandler.java

示例9: createSecurityIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
private static SecurityIdentity createSecurityIdentity(Principal principal, Set<String> roles) {
    ServerAuthenticationContext serverAuthenticationContext = INFLOW_SECURITY_DOMAIN.createNewAuthenticationContext();
    try {
        serverAuthenticationContext.verifyEvidence(new EvidenceWithRoles(principal, roles));
        serverAuthenticationContext.authorize();
    } catch (RealmUnavailableException e) {
        // As the domain is backed by a dummy realm that never throws this Exception it is impossible for it to be thrown.
        throw new IllegalStateException(e);
    }

    return serverAuthenticationContext.getAuthorizedIdentity();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:IdentityAddressProtocolUtil.java

示例10: getRealmIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public RealmIdentity getRealmIdentity(Principal principal) throws RealmUnavailableException {
    try {
        Properties users = getProperties();

        String name = principal.getName();
        return new RealmIdentityImpl(principal, users.getProperty(name));
    } catch (IOException e) {
        throw new RealmUnavailableException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:PropertiesCallbackHandler.java

示例11: getAuthorizationIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException {
    Map<String, List<String>> groupsAttributeMap = new HashMap<String, List<String>>();
    groupsAttributeMap.put("GROUPS", Arrays.asList(groups));

    return AuthorizationIdentity.basicIdentity(new MapAttributes(Collections.unmodifiableMap(groupsAttributeMap)));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:PlugInSubjectSupplemental.java

示例12: getAuthorizationIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException {
    Set<String> groups = getGroups();
    if (groups != null && groups.size() > 0) {
        Map<String, Set<String>> groupsAttributeMap = new HashMap<String, Set<String>>();
        groupsAttributeMap.put("GROUPS",Collections.unmodifiableSet(groups));

        return AuthorizationIdentity.basicIdentity(new MapAttributes(Collections.unmodifiableMap(groupsAttributeMap)));
    } else {
        SECURITY_LOGGER.tracef("No groups found for identity '%s' in LDAP file.", principal.getName());
        return AuthorizationIdentity.EMPTY;
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:LdapSubjectSupplementalService.java

示例13: getGroups

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
private synchronized Set<String> getGroups() throws RealmUnavailableException {
    if (groups == null) {
        try {
            groups = ldapGroupSearcher.loadGroups(Collections.singleton(principal.getName()));
        } catch (IOException e) {
            throw new RealmUnavailableException(e);
        }
    }

    return groups;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:LdapSubjectSupplementalService.java

示例14: getRealmIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public RealmIdentity getRealmIdentity(Evidence evidence) throws RealmUnavailableException {
    try {
        sharedStateLocal.set(new HashMap<>());
        return wrapped.getRealmIdentity(evidence);
    } finally {
        sharedStateLocal.remove();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:SecurityRealmService.java

示例15: getRealmIdentity

import org.wildfly.security.auth.server.RealmUnavailableException; //导入依赖的package包/类
@Override
public RealmIdentity getRealmIdentity(Principal principal) throws RealmUnavailableException {
    try {
        Properties groups = getProperties();

        String name = principal.getName();
        return new RealmIdentityImpl(principal, groups.getProperty(name, "").trim());
    } catch (IOException e) {
        throw new RealmUnavailableException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:PropertiesSubjectSupplemental.java


注:本文中的org.wildfly.security.auth.server.RealmUnavailableException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。