本文整理汇总了Java中org.restlet.security.SecretVerifier类的典型用法代码示例。如果您正苦于以下问题:Java SecretVerifier类的具体用法?Java SecretVerifier怎么用?Java SecretVerifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SecretVerifier类属于org.restlet.security包,在下文中一共展示了SecretVerifier类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: verify
import org.restlet.security.SecretVerifier; //导入依赖的package包/类
private int verify(String clientId, char[] clientSecret) {
ClientManager clients = (ClientManager) context.getAttributes().get(ClientManager.class.getName());
Client client = clients.findById(clientId);
if (client == null) {
return RESULT_UNKNOWN;
}
char[] s = client.getClientSecret();
boolean anull = false;
if( (s == null) || (s.length == 0)) anull = true;
boolean bnull = false;
if( (clientSecret == null) || (clientSecret.length == 0)) bnull = true;
if( anull == true && bnull == true) return RESULT_VALID;
if (!SecretVerifier.compare(s, clientSecret)) {
return RESULT_INVALID;
}
return RESULT_VALID;
}
开发者ID:lathil,项目名称:Ptoceti,代码行数:21,代码来源:BugFixClientVerifier.java
示例2: getPage
import org.restlet.security.SecretVerifier; //导入依赖的package包/类
/**
* 成功したらredirectTemporary(uri)でリダイレクト、"login.html".
* @return 戻り値(ResultRepresentation)
* @throws OAuthException OAuth処理の例外
*/
public static Representation getPage() throws OAuthException {
getLogger().info("Get Login");
ResultRepresentation resultRepresentation = new ResultRepresentation();
resultRepresentation.setResult(false);
String userId = getQueryValue(USER_ID);
HashMap<String, Object> data = new HashMap<String, Object>();
if (userId != null && !userId.isEmpty()) {
String password = getQueryValue(PASSWORD);
getLogger().info("User=" + userId + ", Pass=" + password);
SampleUser sampleUser = LocalOAuth2Main.getSampleUserManager()
.findUserById(userId);
if (sampleUser == null) {
data.put("error", "Authentication failed.");
data.put("error_description", "ID is invalid.");
resultRepresentation.setError("Authentication failed.", "ID is invalid.");
} else {
boolean result = SecretVerifier.compare(password.toCharArray(),
sampleUser.getPassword());
if (result) {
getAuthSession().setScopeOwner(userId);
String uri = getQueryValue(CONTINUE);
getLogger().info("URI: " + uri);
addResultValue(RESULT, "true");
addResultValue(REDIRECT_URL, uri);
getLogger().info("redirectTemporary(uri)=" + uri);
resultRepresentation.setResult(true);
return resultRepresentation;
} else {
data.put("error", "Authentication failed.");
data.put("error_description", "Password is invalid.");
resultRepresentation.setError("Authentication failed.", "Password is invalid.");
}
}
}
return resultRepresentation;
}
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:49,代码来源:LoginPageServerResource.java
示例3: createInboundRoot
import org.restlet.security.SecretVerifier; //导入依赖的package包/类
/**
* Creates a root Restlet that will receive all incoming calls.
*/
@Override
public synchronized Restlet createInboundRoot() {
Verifier verifier = new SecretVerifier() {
@Override
public boolean verify(String username, char[] password) throws IllegalArgumentException {
boolean verified = ActivitiUtil.getIdentityService().checkPassword(username, new String(password));
return verified;
}
};
authenticator = new ChallengeAuthenticator(null, true, ChallengeScheme.HTTP_BASIC,
"Activiti Realm") {
@Override
protected boolean authenticate(Request request, Response response) {
if (request.getChallengeResponse() == null) {
return false;
} else {
return super.authenticate(request, response);
}
}
};
authenticator.setVerifier(verifier);
Router router = new Router(getContext());
router.attachDefault(DefaultResource.class);
router.attach("/process-engine", ProcessEngineResource.class);
router.attach("/login", LoginResource.class);
router.attach("/user/{userId}", UserResource.class);
router.attach("/user/{userId}/groups", UserGroupsResource.class);
router.attach("/group/{groupId}", GroupResource.class);
router.attach("/groups/{groupId}/users", GroupUsersResource.class);
router.attach("/process-definitions", ProcessDefinitionsResource.class);
router.attach("/process-instances", ProcessInstancesResource.class);
router.attach("/process-instance", ProcessInstanceResource.class);
router.attach("/processInstance/{processInstanceId}/diagram", ProcessInstanceDiagramResource.class);
router.attach("/process-definition/{processDefinitionId}/form", ProcessDefinitionFormResource.class);
router.attach("/tasks", TasksResource.class);
router.attach("/tasks-summary", TasksSummaryResource.class);
router.attach("/task/{taskId}", TaskResource.class);
router.attach("/task/{taskId}/form", TaskFormResource.class);
router.attach("/task/{taskId}/{operation}", TaskOperationResource.class);
router.attach("/form/{taskId}/properties", TaskPropertiesResource.class);
router.attach("/deployments", DeploymentsResource.class);
router.attach("/deployment", DeploymentUploadResource.class);
router.attach("/deployments/delete", DeploymentsDeleteResource.class);
router.attach("/deployment/{deploymentId}", DeploymentDeleteResource.class);
router.attach("/management/jobs", JobsResource.class);
router.attach("/management/job/{jobId}", JobResource.class);
router.attach("/management/job/{jobId}/execute", JobExecuteResource.class);
router.attach("/management/jobs/execute", JobsExecuteResource.class);
router.attach("/management/tables", TablesResource.class);
router.attach("/management/table/{tableName}", TableResource.class);
router.attach("/management/table/{tableName}/data", TableDataResource.class);
authenticator.setNext(router);
return authenticator;
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:73,代码来源:ActivitiRestApplication.java
示例4: onStart
import org.restlet.security.SecretVerifier; //导入依赖的package包/类
@Override
public void onStart() {
try {
super.onStart();
component = new Component();
component.getClients().add(Protocol.FILE);
//TODO: To test with the restlet 2.1 Maybe the maxTotalConnections could be avoided
// see: http://restlet-discuss.1400322.n2.nabble.com/rejectedExecution-td4513620.html
//component.getServers().add(Protocol.HTTP, SERVER_PORT);
Server server = new Server(Protocol.HTTP, SERVER_PORT);
component.getServers().add(server);
server.getContext().getParameters().add("maxTotalConnections", "50");
//end TODO
// enable SSL
Server SSLserver = new Server(Protocol.HTTPS, configuration.getIntProperty("SSL_PORT", SERVER_PORT + 2 ));
component.getServers().add(SSLserver);
Series<Parameter> parameters = SSLserver.getContext().getParameters();
parameters.add("sslContextFactory", "org.restlet.ext.ssl.PkixSslContextFactory");
// Certificate's data is taken from config file
parameters.add("keystorePath", new File(this.getFile().getParent() + "/data/" + configuration.getStringProperty("KEYSTORE_FILE", "keystore")).getAbsolutePath());
parameters.add("keystorePassword", configuration.getStringProperty("KEYSTORE_PASSWORD", "password"));
parameters.add("keyPassword", configuration.getStringProperty("KEYSTORE_PASSWORD", "password"));
parameters.add("keystoreType", configuration.getStringProperty("KEYSTORE_TYPE", "JKS"));
// end enable SSL
// Engine.getInstance().getRegisteredServers().clear();
// Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(server));
// Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(SSLserver));
component.getClients().add(Protocol.FILE);
OriginFilter originFilter = new OriginFilter(component.getContext().createChildContext(),this);
Application FDapp = new FreedomRestServer(Info.PATHS.PATH_RESOURCES_FOLDER.getAbsolutePath(), component.getContext().createChildContext());
if (getApi().getAuth().isInited()) {
// Instantiates a Verifier of identifier/secret couples based on Freedomotic Auth
Verifier v = new SecretVerifier() {
@Override
public int verify(String identifier, char[] secret) {
if (getApi().getAuth().login(identifier, secret)) {
return RESULT_VALID;
}
return RESULT_INVALID;
}
};
// Guard the restlet with BASIC authentication.
ChallengeAuthenticator guard = new ChallengeAuthenticator(component.getContext().createChildContext(), false, ChallengeScheme.HTTP_BASIC, "testRealm", v);
// WIP: Guard the restlet with DIGEST authentication.
DigestAuthenticator dguard = new DigestAuthenticator(component.getContext().createChildContext(), "DigestRealm", configuration.getStringProperty("DIGEST_SECRET", "s3cr3t"));
dguard.setOptional(true);
// TODO: set proper verifier before enabling DIGEST AUTH.
originFilter.setNext(guard);
guard.setNext(FDapp);
} else {
originFilter.setNext(FDapp);
}
component.getDefaultHost().attachDefault(originFilter);
component.start();
freedomoticApi = getApi();
} catch (Exception ex) {
Logger.getLogger(RestApi.class.getName()).log(Level.SEVERE, null, ex);
}
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:69,代码来源:RestApi.java
注:本文中的org.restlet.security.SecretVerifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论