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


Java AuthorizeCallback.setAuthorized方法代码示例

本文整理汇总了Java中javax.security.sasl.AuthorizeCallback.setAuthorized方法的典型用法代码示例。如果您正苦于以下问题:Java AuthorizeCallback.setAuthorized方法的具体用法?Java AuthorizeCallback.setAuthorized怎么用?Java AuthorizeCallback.setAuthorized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.security.sasl.AuthorizeCallback的用法示例。


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

示例1: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    String authorizationID = ac.getAuthorizationID();

    LOG.info("Successfully authenticated client: authenticationID=" + authenticationID
            + ";  authorizationID=" + authorizationID + ".");
    ac.setAuthorized(true);

    // canonicalize authorization id according to system properties:
    // zookeeper.kerberos.removeRealmFromPrincipal(={true,false})
    // zookeeper.kerberos.removeHostFromPrincipal(={true,false})
    KerberosName kerberosName = new KerberosName(authenticationID);
    try {
        StringBuilder userNameBuilder = new StringBuilder(kerberosName.getShortName());
        if (shouldAppendHost(kerberosName)) {
            userNameBuilder.append("/").append(kerberosName.getHostName());
        }
        if (shouldAppendRealm(kerberosName)) {
            userNameBuilder.append("@").append(kerberosName.getRealm());
        }
        LOG.info("Setting authorizedID: " + userNameBuilder);
        ac.setAuthorizedID(userNameBuilder.toString());
    } catch (IOException e) {
        LOG.error("Failed to set name based on Kerberos authentication rules.");
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:27,代码来源:SaslServerCallbackHandler.java

示例2: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    String authorizationID = ac.getAuthorizationID();

    LOG.info("Successfully authenticated client: authenticationID=" + authenticationID
            + ";  authorizationID=" + authorizationID + ".");
    ac.setAuthorized(true);

    // canonicalize authorization id according to system properties:
    // zookeeper.kerberos.removeRealmFromPrincipal(={true,false})
    // zookeeper.kerberos.removeHostFromPrincipal(={true,false})
    KerberosName kerberosName = new KerberosName(authenticationID);
    try {
        StringBuilder userNameBuilder = new StringBuilder(kerberosName.getShortName());
        if (shouldAppendHost(kerberosName)) {
            userNameBuilder.append("/").append(kerberosName.getHostName());
        }
        if (shouldAppendRealm(kerberosName)) {
            userNameBuilder.append("@").append(kerberosName.getRealm());
        }
        LOG.info("Setting authorizedID: " + userNameBuilder);
        ac.setAuthorizedID(userNameBuilder.toString());
    } catch (IOException e) {
        LOG.error("Failed to set name based on Kerberos authentication rules.", e);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:27,代码来源:SaslServerCallbackHandler.java

示例3: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    String authorizationID = ac.getAuthorizationID();

    LOG.info("Successfully authenticated client: authenticationID={}; authorizationID={}.", authenticationID,
            authorizationID);
    ac.setAuthorized(true);

    KerberosName kerberosName = KerberosName.parse(authenticationID);
    try {
        String userName = kerberosShortNamer.shortName(kerberosName);
        LOG.info("Setting authorizedID: {}", userName);
        ac.setAuthorizedID(userName);
    } catch (IOException e) {
        LOG.error("Failed to set name for '{}' based on Kerberos authentication rules.", kerberosName, e);
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:18,代码来源:SaslServerCallbackHandler.java

示例4: handle

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callback;
            nameCallback.setName(nameCallback.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callback;
            passwordCallback.setPassword(TestJaasConfig.PASSWORD.toCharArray());
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(realmCallback.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authCallback = (AuthorizeCallback) callback;
            if (TestJaasConfig.USERNAME.equals(authCallback.getAuthenticationID())) {
                authCallback.setAuthorized(true);
                authCallback.setAuthorizedID(authCallback.getAuthenticationID());
            }
        }
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:TestDigestLoginModule.java

示例5: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    String authorizationID = ac.getAuthorizationID();

    LOG.info("Successfully authenticated client: authenticationID={}; authorizationID={}.", authenticationID,
            authorizationID);
    ac.setAuthorized(true);

    KerberosName kerberosName = KerberosName.parse(authenticationID);
    try {
        String userName = kerberosShortNamer.shortName(kerberosName);
        LOG.info("Setting authorizedID: {}", userName);
        ac.setAuthorizedID(userName);
    } catch (IOException e) {
        LOG.error("Failed to set name based on Kerberos authentication rules.");
    }
}
 
开发者ID:txazo,项目名称:kafka,代码行数:18,代码来源:SaslServerCallbackHandler.java

示例6: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    String authorizationID = ac.getAuthorizationID();

    LOG.info("Successfully authenticated client: authenticationID=" + authenticationID
        + ";  authorizationID=" + authorizationID + ".");
    ac.setAuthorized(true);

    KerberosName kerberosName = new KerberosName(authenticationID);
    try {
        StringBuilder userNameBuilder = new StringBuilder(kerberosName.getShortName());
        userNameBuilder.append("/").append(kerberosName.getHostName());
        userNameBuilder.append("@").append(kerberosName.getRealm());
        LOG.info("Setting authorizedID: " + userNameBuilder);
        ac.setAuthorizedID(userNameBuilder.toString());
    } catch (IOException e) {
        LOG.severe("Failed to set name based on Kerberos authentication rules.");
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:20,代码来源:SaslNettyServer.java

示例7: handle

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
@Override
public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
  for (final Callback callback : callbacks) {
    if (callback instanceof AuthorizeCallback) {
      final AuthorizeCallback authorizeCallback = (AuthorizeCallback) callback;
      if (!authorizeCallback.getAuthenticationID()
          .equals(authorizeCallback.getAuthorizationID())) {
        throw new SaslException("Drill expects authorization ID and authentication ID to match. " +
            "Use inbound impersonation feature so one entity can act on behalf of another.");
      } else {
        authorizeCallback.setAuthorized(true);
      }
    } else {
      throw new UnsupportedCallbackException(callback);
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:18,代码来源:KerberosFactory.java

示例8: handle

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for(Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback)callback;
            nameCallback.setName("user");
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback)callback;
            passwordCallback.setPassword(password.toCharArray());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authorizeCallback = (AuthorizeCallback)callback;
            authorizeCallback.setAuthorized(authorizeCallback.getAuthenticationID().equals(authorizeCallback.getAuthorizationID()));
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(REALM);
        } else {
            throw new UnsupportedCallbackException(callback);
        }
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:21,代码来源:SASLTest.java

示例9: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    String authorizationID = ac.getAuthorizationID();

    LOG.severe("Successfully authenticated client: authenticationID=" + authenticationID
        + ";  authorizationID=" + authorizationID + ".");
    ac.setAuthorized(true);

    KerberosName kerberosName = new KerberosName(authenticationID);
    try {
        StringBuilder userNameBuilder = new StringBuilder(kerberosName.getShortName());
        userNameBuilder.append("/").append(kerberosName.getHostName());
        userNameBuilder.append("@").append(kerberosName.getRealm());
        LOG.severe("Setting authorizedID: " + userNameBuilder);
        ac.setAuthorizedID(userNameBuilder.toString());
    } catch (IOException e) {
        LOG.severe("Failed to set name based on Kerberos authentication rules.");
    }
}
 
开发者ID:diennea,项目名称:majordodo,代码行数:20,代码来源:SaslNettyServer.java

示例10: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    LOG.info("Successfully authenticated client: authenticationID=" + authenticationID + " authorizationID= " + ac.getAuthorizationID());

    // if authorizationId is not set, set it to authenticationId.
    if (ac.getAuthorizationID() == null) {
        ac.setAuthorizedID(authenticationID);
    }

    // When authNid and authZid are not equal , authNId is attempting to impersonate authZid, We
    // add the authNid as the real user in reqContext's subject which will be used during authorization.
    if (!ac.getAuthenticationID().equals(ac.getAuthorizationID())) {
        ReqContext.context().setRealPrincipal(new SaslTransportPlugin.User(ac.getAuthenticationID()));
    }

    ac.setAuthorized(true);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:18,代码来源:ServerCallbackHandler.java

示例11: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    LOG.info("Successfully authenticated client: authenticationID = " + authenticationID + " authorizationID = " + ac.getAuthorizationID());

    // if authorizationId is not set, set it to authenticationId.
    if (ac.getAuthorizationID() == null) {
        ac.setAuthorizedID(authenticationID);
    }

    // When authNid and authZid are not equal , authNId is attempting to impersonate authZid, We
    // add the authNid as the real user in reqContext's subject which will be used during authorization.
    if (!authenticationID.equals(ac.getAuthorizationID())) {
        LOG.info("Impersonation attempt  authenticationID = " + ac.getAuthenticationID() + " authorizationID = " + ac.getAuthorizationID());
        ReqContext.context().setRealPrincipal(new SaslTransportPlugin.User(ac.getAuthenticationID()));
    }

    ac.setAuthorized(true);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:19,代码来源:ServerCallbackHandler.java

示例12: test01

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
/**
 * Test for <code>AuthorizeCallback(String authnID, String authzID)</code>
 * and get/set methods
 */
public void test01() {
    AuthorizeCallback auth = new AuthorizeCallback(null, null);
    assertNull(auth.getAuthenticationID());
    assertNull(auth.getAuthorizationID());
    assertNull(auth.getAuthorizedID());
    assertFalse(auth.isAuthorized());

    auth.setAuthorized(true);
    assertTrue(auth.isAuthorized());
    assertNull(auth.getAuthorizedID());

    auth.setAuthorized(false);
    assertNull(auth.getAuthorizedID());
    assertFalse(auth.isAuthorized());

    auth.setAuthorizedID("ZZZ");
    auth.setAuthorized(true);
    assertEquals(auth.getAuthorizedID(), "ZZZ");
    assertNull(auth.getAuthorizationID());
    assertTrue(auth.isAuthorized());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:AuthorizeCallbackTest.java

示例13: handle

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof AuthorizeCallback) {
            AuthorizeCallback acb = (AuthorizeCallback) current;
            boolean authorized = acb.getAuthenticationID().equals(acb.getAuthorizationID());
            if (authorized == false) {
                SECURITY_LOGGER.tracef(
                        "Checking 'AuthorizeCallback', authorized=false, authenticationID=%s, authorizationID=%s.",
                        acb.getAuthenticationID(), acb.getAuthorizationID());
            }
            acb.setAuthorized(authorized);
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ClientCertCallbackHandler.java

示例14: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
@SuppressWarnings("unused")
protected void handleAuthorizeCallback(AuthorizeCallback authCallback) {
	String authenId = authCallback.getAuthenticationID();

	if (log.isLoggable(Level.FINEST)) {
		log.log(Level.FINEST, "AuthorizeCallback: authenId: {0}", authenId);
	}

	String authorId = authCallback.getAuthorizationID();

	if (log.isLoggable(Level.FINEST)) {
		log.log(Level.FINEST, "AuthorizeCallback: authorId: {0}", authorId);
	}
	if (AbstractSasl.isAuthzIDIgnored() || authenId.equals(authorId)) {
		authCallback.setAuthorized(true);
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:18,代码来源:AuthRepoPlainCallbackHandler.java

示例15: handleAuthorizeCallback

import javax.security.sasl.AuthorizeCallback; //导入方法依赖的package包/类
protected void handleAuthorizeCallback(AuthorizeCallback authCallback) {
	String authenId = authCallback.getAuthenticationID();

	if (log.isLoggable(Level.FINEST)) {
		log.log(Level.FINEST, "AuthorizeCallback: authenId: {0}", authenId);
	}

	String authorId = authCallback.getAuthorizationID();

	if (log.isLoggable(Level.FINEST)) {
		log.log(Level.FINEST, "AuthorizeCallback: authorId: {0}", authorId);
	}
	if (AbstractSasl.isAuthzIDIgnored() || authenId.equals(authorId)) {
		authCallback.setAuthorized(true);
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:17,代码来源:ScramCallbackHandler.java


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