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


Java Credentials类代码示例

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


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

示例1: before

import com.hazelcast.security.Credentials; //导入依赖的package包/类
@Override
public void before(Credentials credentials, String objectType, String objectName,
                   String methodName, Parameters parameters) throws AccessControlException {
    if (objectName.equals(DENIED_MAP_NAME)) {
        throw new RuntimeException("Denied Map!!!");
    }
    if (methodName.equals(DENIED_METHOD)) {
        throw new RuntimeException("Denied Method!!!");
    }
    final Object firstParam = parameters.get(0);
    final Object secondParam = parameters.get(1);
    if (firstParam.equals(DENIED_KEY)) {
        throw new RuntimeException("Denied Key!!!");
    }
    if (secondParam.equals(DENIED_VALUE)) {
        throw new RuntimeException("Denied Value!!!");
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:19,代码来源:HazelcastSecurityInterceptor.java

示例2: readData

import com.hazelcast.security.Credentials; //导入依赖的package包/类
@Override
public void readData(DataInput in) throws IOException {
    packetVersion = in.readByte();
    buildNumber = in.readInt();
    boolean hasTo = in.readBoolean();
    if (hasTo) {
        to = new Address();
        to.readData(in);
    }
    address = new Address();
    address.readData(in);
    nodeType = NodeType.create(in.readInt());
    config = new Config();
    config.readData(in);
    uuid = in.readUTF();
    boolean hasCredentials = in.readBoolean();
    if (hasCredentials) {
        credentials = (Credentials) SerializationHelper.readObject(in);
        if (credentials != null) {
            credentials.setEndpoint(address.getHost());
        }
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:24,代码来源:JoinRequest.java

示例3: bind

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public void bind(Connection connection, Credentials credentials) throws IOException {
        logger.log(Level.FINEST, connection + " -> "
                + connection.getAddress().getHostName() + ":" + connection.getSocket().getLocalPort());
        auth(connection, credentials);
//        Bind b = null;
//        try {
//            b = new Bind(new Address(connection.getAddress().getHostName(), connection.getSocket().getLocalPort()));
//        } catch (UnknownHostException e) {
//            logger.log(Level.WARNING, e.getMessage() + " while creating the bind package.");
//            throw e;
//        }
//        System.out.println("Client Bind = " + b);
//        Packet bind = new Packet();
//        bind.set("remotelyProcess", ClusterOperation.REMOTELY_PROCESS, toByte(null), toByte(b));
//        write(connection, bind);
    }
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:17,代码来源:DefaultClientBinder.java

示例4: createJoinInfo

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public JoinInfo createJoinInfo(boolean withCredentials) {
    final JoinInfo jr = new JoinInfo(this.getLogger(JoinInfo.class.getName()), true, address, config, getLocalNodeType(),
            Packet.PACKET_VERSION, buildNumber, clusterImpl.getMembers().size(), 0, localMember.getUuid());
    if (withCredentials && securityContext != null) {
        Credentials c = securityContext.getCredentialsFactory().newCredentials();
        jr.setCredentials(c);
    }
    return jr;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:10,代码来源:Node.java

示例5: after

import com.hazelcast.security.Credentials; //导入依赖的package包/类
@Override
public void after(Credentials credentials, String objectType, String objectName,
                  String methodName, Parameters parameters) {
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:5,代码来源:HazelcastSecurityInterceptor.java

示例6: newCredentials

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public Credentials newCredentials() {
    return null;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:4,代码来源:DummyCredentialsFactory.java

示例7: setCredentials

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public void setCredentials(Credentials credentials) {
    this.credentials = credentials;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:4,代码来源:JoinRequest.java

示例8: getCredentials

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public Credentials getCredentials() {
    return credentials;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:4,代码来源:JoinRequest.java

示例9: processCall

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public void processCall(Node node, Packet packet) {
            final Credentials credentials = (Credentials) toObject(packet.getValueData());
            boolean authenticated = false;
            if (credentials == null) {
                authenticated = false;
                logger.log(Level.SEVERE, "Could not retrieve Credentials object!");
            } else if (node.securityContext != null) {
                final Socket endpointSocket = packet.conn.getSocketChannelWrapper().socket();
                // TODO: check!!!
                credentials.setEndpoint(endpointSocket.getInetAddress().getHostAddress());
                try {
                    LoginContext lc = node.securityContext.createClientLoginContext(credentials);
                    lc.login();
                    getClientEndpoint(packet.conn).setLoginContext(lc);
                    authenticated = true;
                } catch (LoginException e) {
                    logger.log(Level.WARNING, e.getMessage(), e);
                    authenticated = false;
                }
            } else {
                if (credentials instanceof UsernamePasswordCredentials) {
                    final UsernamePasswordCredentials usernamePasswordCredentials = (UsernamePasswordCredentials) credentials;
                    final String nodeGroupName = factory.getConfig().getGroupConfig().getName();
                    final String nodeGroupPassword = factory.getConfig().getGroupConfig().getPassword();
                    authenticated = (nodeGroupName.equals(usernamePasswordCredentials.getUsername())
                            && nodeGroupPassword.equals(usernamePasswordCredentials.getPassword()));
                } else {
                    authenticated = false;
                    logger.log(Level.SEVERE, "Hazelcast security is disabled.\nUsernamePasswordCredentials or cluster group-name" +
                            " and group-password should be used for authentication!\n" +
                            "Current credentials type is: " + credentials.getClass().getName());
                }
            }
            logger.log((authenticated ? Level.INFO : Level.WARNING), "received auth from " + packet.conn
//            		+ ", this group name:" + nodeGroupName + ", auth group name:" + groupName
                    + ", " + (authenticated ?
                    "successfully authenticated" : "authentication failed"));
            packet.clearForResponse();
            packet.setValue(toData(authenticated));
            if (!authenticated) {
                node.clientHandlerService.removeClientEndpoint(packet.conn);
            } else {
                ClientEndpoint clientEndpoint = node.clientHandlerService.getClientEndpoint(packet.conn);
                clientEndpoint.authenticated();
            }
        }
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:47,代码来源:ClientHandlerService.java

示例10: setCredentials

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public ClientConfig setCredentials(Credentials credentials) {
    this.credentials = credentials;
    return this;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:5,代码来源:ClientConfig.java

示例11: processCall

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public void processCall(Node node, Packet packet) {
    final Credentials credentials = (Credentials) toObject(packet.getValueData());
    boolean authenticated = false;
    final Socket socket = packet.conn.getSocketChannelWrapper().socket();
    if (credentials == null) {
        authenticated = false;
        logger.log(Level.SEVERE, "Could not retrieve Credentials object!");
    } else if (node.securityContext != null) {
        credentials.setEndpoint(socket.getInetAddress().getHostAddress());
        try {
            LoginContext lc = node.securityContext.createClientLoginContext(credentials);
            lc.login();
            getClientEndpoint(packet.conn).setLoginContext(lc);
            authenticated = true;
        } catch (LoginException e) {
            logger.log(Level.WARNING, e.getMessage(), e);
            authenticated = false;
        }
    } else {
        if (credentials instanceof UsernamePasswordCredentials) {
            final UsernamePasswordCredentials usernamePasswordCredentials = (UsernamePasswordCredentials) credentials;
            final String nodeGroupName = factory.getConfig().getGroupConfig().getName();
            final String nodeGroupPassword = factory.getConfig().getGroupConfig().getPassword();
            authenticated = (nodeGroupName.equals(usernamePasswordCredentials.getUsername())
                    && nodeGroupPassword.equals(usernamePasswordCredentials.getPassword()));
        } else {
            authenticated = false;
            logger.log(Level.SEVERE, "Hazelcast security is disabled.\nUsernamePasswordCredentials or cluster group-name" +
                    " and group-password should be used for authentication!\n" +
                    "Current credentials type is: " + credentials.getClass().getName());
        }
    }
    logger.log((authenticated ? Level.INFO : Level.WARNING), "received auth from " + packet.conn
            + ", " + (authenticated ?
            "successfully authenticated" : "authentication failed"));
    packet.clearForResponse();
    packet.setValue(toData(authenticated));
    if (!authenticated) {
        node.clientHandlerService.removeClientEndpoint(packet.conn);
    } else {
        ClientEndpoint clientEndpoint = node.clientHandlerService.getClientEndpoint(packet.conn);
        clientEndpoint.authenticated();
        Bind bind = new Bind(new Address(socket.getInetAddress(), socket.getPort()));
        bind.setConnection(packet.conn);
        bind.setNode(node);
        node.clusterService.enqueueAndWait(bind);
    }
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:49,代码来源:ClientHandlerService.java

示例12: bind

import com.hazelcast.security.Credentials; //导入依赖的package包/类
public void bind(Connection connection, Credentials credentials) throws IOException; 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:2,代码来源:ClientBinder.java


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